function newpoints_plugin_install() { global $db, $mybb; $collation = $db->build_create_table_collation(); // create tables if (!$db->table_exists("newpoints_settings")) { $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_settings` (\n\t\t `sid` int(10) UNSIGNED NOT NULL auto_increment,\n\t\t `plugin` varchar(100) NOT NULL default '',\n\t\t `name` varchar(100) NOT NULL default '',\n\t\t `title` varchar(100) NOT NULL default '',\n\t\t `description` text NOT NULL,\n\t\t `type` text NOT NULL,\n\t\t `value` text NOT NULL,\n\t\t `disporder` smallint(5) UNSIGNED NOT NULL default '0',\n\t\t PRIMARY KEY (`sid`)\n\t\t\t) ENGINE=MyISAM{$collation}"); } if (!$db->table_exists("newpoints_log")) { $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_log` (\n\t\t `lid` bigint(30) UNSIGNED NOT NULL auto_increment,\n\t\t `action` varchar(100) NOT NULL default '',\n\t\t `data` text NOT NULL,\n\t\t `date` bigint(30) UNSIGNED NOT NULL default '0',\n\t\t `uid` bigint(30) UNSIGNED NOT NULL default '0',\n\t\t `username` varchar(100) NOT NULL default '',\n\t\t PRIMARY KEY (`lid`)\n\t\t\t) ENGINE=MyISAM{$collation}"); } if (!$db->table_exists("newpoints_forumrules")) { $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_forumrules` (\n\t\t `rid` bigint(30) UNSIGNED NOT NULL auto_increment,\n\t\t `fid` int(10) UNSIGNED NOT NULL default '0',\n\t\t `name` varchar(100) NOT NULL default '',\n\t\t `description` text NOT NULL,\n\t\t `rate` float NOT NULL default '1',\n\t\t `pointsview` DECIMAL(16,2) NOT NULL default '0',\n\t\t `pointspost` DECIMAL(16,2) NOT NULL default '0',\n\t\t PRIMARY KEY (`rid`)\n\t\t\t) ENGINE=MyISAM{$collation}"); } if (!$db->table_exists("newpoints_grouprules")) { $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_grouprules` (\n\t\t `rid` bigint(30) UNSIGNED NOT NULL auto_increment,\n\t\t `gid` int(10) UNSIGNED NOT NULL default '0',\n\t\t `name` varchar(100) NOT NULL default '',\n\t\t `description` text NOT NULL,\n\t\t `rate` float NOT NULL default '1',\n\t\t `pointsearn` DECIMAL(16,2) UNSIGNED NOT NULL default '0',\n\t\t `period` bigint(30) UNSIGNED NOT NULL default '0',\n\t\t `lastpay` bigint(30) UNSIGNED NOT NULL default '0',\n\t\t PRIMARY KEY (`rid`)\n\t\t\t) ENGINE=MyISAM{$collation}"); } // add settings newpoints_add_setting('newpoints_main_enabled', 'main', 'Is NewPoints enabled?', 'Set to no if you want to disable NewPoints.', 'yesno', 1, 1); newpoints_add_setting('newpoints_main_curname', 'main', 'Currency Name', 'Enter a name for the currency.', 'text', 'Points', 2); newpoints_add_setting('newpoints_main_curprefix', 'main', 'Currency Prefix', 'Enter what you want to display before the number of points.', 'text', '', 3); newpoints_add_setting('newpoints_main_cursuffix', 'main', 'Currency Suffix', 'Enter what you want to display after the number of points.', 'text', '€', 4); newpoints_add_setting('newpoints_main_decimal', 'main', 'Decimal Places', 'Number of decimals to be used.', 'text', '2', 5); newpoints_add_setting('newpoints_main_statsvisible', 'main', 'Statistics visible to users?', 'Set to no if you do not want users to view the statistics.', 'yesno', 1, 6); newpoints_add_setting('newpoints_main_donationsenabled', 'main', 'Donations enabled?', 'Set to no if you want to disable donations.', 'yesno', 1, 7); newpoints_add_setting('newpoints_main_donationspm', 'main', 'Send a PM on donate?', 'Do you want it to automatically send a new private message to a user receiving a donation?', 'yesno', 1, 8); newpoints_add_setting('newpoints_main_stats_lastdonations', 'main', 'Last donations', 'Number of last donations to show.', 'text', 10, 9); newpoints_add_setting('newpoints_main_stats_richestusers', 'main', 'Richest Users', 'Number of richest users to show.', 'text', 10, 9); // income settings newpoints_add_setting('newpoints_income_newpost', 'income', 'New Post', 'Amount of points received on new post.', 'text', '10', 1); newpoints_add_setting('newpoints_income_newthread', 'income', 'New Thread', 'Amount of points received on new thread.', 'text', '20', 2); newpoints_add_setting('newpoints_income_newpoll', 'income', 'New Poll', 'Amount of points received on new poll.', 'text', '15', 3); newpoints_add_setting('newpoints_income_perchar', 'income', 'Per Character', 'Amount of points received per character (in new thread and new post).', 'text', '0.01', 4); newpoints_add_setting('newpoints_income_minchar', 'income', 'Minimum Characters', 'Minimum characters required in order to receive the amount of points per character.', 'text', '15', 5); newpoints_add_setting('newpoints_income_newreg', 'income', 'New Registration', 'Amount of points received by the user when registering.', 'text', '50', 6); newpoints_add_setting('newpoints_income_pervote', 'income', 'Per Poll Vote', 'Amount of points received by the user who votes.', 'text', '5', 7); newpoints_add_setting('newpoints_income_perreply', 'income', 'Per Reply', 'Amount of points received by the author of the thread, when someone replies to it.', 'text', '2', 8); newpoints_add_setting('newpoints_income_pmsent', 'income', 'Per PM Sent', 'Amount of points received everytime a user sends a private message.', 'text', '1', 9); newpoints_add_setting('newpoints_income_perrate', 'income', 'Per Rate', 'Amount of points received everytime a user rates a thread.', 'text', '0.05', 9); newpoints_add_setting('newpoints_income_pageview', 'income', 'Per Page View', 'Amount of points received everytime a user views a page.', 'text', '0', 10); newpoints_add_setting('newpoints_income_visit', 'income', 'Per Visit', 'Amount of points received everytime a user visits the forum. ("visits" = new MyBB session (expires after 15 minutes))', 'text', '0.1', 11); newpoints_add_setting('newpoints_income_referral', 'income', 'Per Referral', 'Amount of points received everytime a user is referred. (the referred user is who receives the points)', 'text', '5', 12); //rebuild_settings(); newpoints_rebuild_settings_cache(); newpoints_rebuild_rules_cache(); // add points field if (!$db->field_exists('newpoints', 'users')) { $db->write_query("ALTER TABLE `" . TABLE_PREFIX . "users` ADD `newpoints` DECIMAL(16,2) NOT NULL DEFAULT '0';"); } // create task $new_task = array("title" => "Backup NewPoints", "description" => "Creates a backup of NewPoints default tables and users\\'s points.", "file" => "backupnewpoints", "minute" => '0', "hour" => '0', "day" => '*', "month" => '*', "weekday" => '0', "enabled" => '0', "logging" => '1'); $new_task['nextrun'] = 0; // once the task is enabled, it will generate a nextrun date $tid = $db->insert_query("tasks", $new_task); }
function upgrade195_run() { global $db; newpoints_rebuild_settings_cache(); newpoints_rebuild_rules_cache(); }
unset($active_plugins[$codename]); } } // Update plugin cache $plugins_cache['active'] = $active_plugins; $cache->update("newpoints_plugins", $plugins_cache); // Log admin action log_admin_action($codename, $install_uninstall); if ($mybb->input['action'] == "activate") { $plugins->run_hooks("newpoints_admin_plugins_activate_commit"); } else { $plugins->run_hooks("newpoints_admin_plugins_deactivate_commit"); } // Rebuild settings cache $array = array(); newpoints_rebuild_settings_cache($array); flash_message($message, 'success'); admin_redirect("index.php?module=newpoints-plugins"); } if (!$mybb->input['action']) { $plugins_cache = $cache->read("newpoints_plugins"); $active_plugins = $plugins_cache['active']; $plugins_list = newpoints_get_plugins(); $plugins->run_hooks("newpoints_admin_plugins_start"); // table $table = new Table(); $table->construct_header($lang->plugin); $table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300)); if (!empty($plugins_list)) { foreach ($plugins_list as $plugin) { require_once MYBB_ROOT . "inc/plugins/newpoints/" . $plugin;
function newpoints_load_settings() { global $mybb, $db, $cache; $settings = $cache->read("newpoints_settings"); if ($settings !== false && !empty($settings)) { foreach ($settings as $name => $value) { $mybb->settings[$name] = $value; } } /* something is wrong so let's rebuild the cache data */ if (empty($settings) || $settings === false) { $settings = array(); newpoints_rebuild_settings_cache($settings); } }