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(); }
admin_redirect("index.php?module=newpoints-grouprules"); } if ($mybb->request_method == "post") { if (!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key']) { $mybb->request_method = "get"; flash_message($lang->newpoints_error, 'error'); admin_redirect("index.php?module=newpoints-grouprules"); } if (!$db->fetch_field($db->simple_select('newpoints_grouprules', 'name', 'rid=' . intval($mybb->input['rid']), array('limit' => 1)), 'name')) { flash_message($lang->newpoints_grouprules_invalid, 'error'); admin_redirect('index.php?module=newpoints-grouprules'); } else { $db->delete_query('newpoints_grouprules', 'rid=' . intval($mybb->input['rid'])); // Rebuild rules cache $array = array(); newpoints_rebuild_rules_cache(); flash_message($lang->newpoints_grouprules_deleted, 'success'); admin_redirect('index.php?module=newpoints-grouprules'); } } else { $mybb->input['rid'] = intval($mybb->input['rid']); $form = new Form("index.php?module=newpoints-grouprules&action=delete_rule&rid={$mybb->input['rid']}&my_post_key={$mybb->post_code}", 'post'); echo "<div class=\"confirm_action\">\n"; echo "<p>{$lang->newpoints_grouprules_deleteconfirm}</p>\n"; echo "<br />\n"; echo "<p class=\"buttons\">\n"; echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes')); echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no')); echo "</p>\n"; echo "</div>\n"; $form->end();