function upgrade11_run() { 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); change_admin_permission("newpoints", "upgrades", 1); newpoints_remove_templates("'newpoints_donate'"); newpoints_add_template('newpoints_donate', ' <html> <head> <title>{$lang->newpoints} - {$lang->newpoints_donate}</title> {$headerinclude} </head> <body> {$header} <table width="100%" border="0" align="center"> <tr> <td valign="top" width="180"> <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead"><strong>{$lang->newpoints_menu}</strong></td> </tr> {$options} </table> </td> <td valign="top"> <form action="newpoints.php" method="POST"> <input type="hidden" name="postcode" value="{$mybb->post_code}"> <input type="hidden" name="action" value="do_donate"> <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead" colspan="2"><strong>{$lang->newpoints_donate}</strong></td> </tr> <tr> <td class="trow1" width="50%"><strong>{$lang->newpoints_user}:</strong><br /><span class="smalltext">{$lang->newpoints_user_desc}</span></td> <td class="trow1" width="50%"><input type="text" name="username" value="{$user[\'username\']}" class="textbox"></td> </tr> <tr> <td class="trow2" width="50%"><strong>{$lang->newpoints_amount}:</strong><br /><span class="smalltext">{$lang->newpoints_amount_desc}</span></td> <td class="trow2" width="50%"><input type="text" name="amount" value="" class="textbox"></td> </tr> <tr> <td class="trow1" width="50%"><strong>{$lang->newpoints_reason}:</strong><br /><span class="smalltext">{$lang->newpoints_reason_desc}</span></td> <td class="trow1" width="50%"><input type="text" name="reason" value="" class="textbox"></td> </tr> <tr> <td class="tfoot" width="100%" colspan="2" align="center"><input type="submit" name="submit" value="{$lang->newpoints_submit}"></td> </tr> </table> </form> </td> </tr> </table> {$footer} </body> </html>'); }
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 newpoints_shop_install() { global $db; $db->write_query("ALTER TABLE `" . TABLE_PREFIX . "users` ADD `newpoints_items` TEXT NOT NULL;"); $db->write_query("ALTER TABLE `" . TABLE_PREFIX . "newpoints_grouprules` ADD `items_rate` DECIMAL(3,3) NOT NULL default '1';"); // add settings newpoints_add_setting('newpoints_shop_sendable', 'newpoints_shop', 'Send items', 'Allow users to send items to other users.', 'yesno', '1', 1); newpoints_add_setting('newpoints_shop_sellable', 'newpoints_shop', 'Sell items', 'Allow users to sell items.', 'yesno', '1', 2); newpoints_add_setting('newpoints_shop_lastpurchases', 'newpoints_shop', 'Last Purchases', 'Number of last purchases to show in statistics.', 'text', '10', 3); newpoints_add_setting('newpoints_shop_percent', 'newpoints_shop', 'Sell Percentage', 'The (discounted) rate at which items can be sold for.', 'text', '0.75', 4); newpoints_add_setting('newpoints_shop_viewothers', 'newpoints_shop', 'Can View Others\' inventories', 'Allow users to view other users\' inventories. Note, admins always are able to view other users\' inventories.', 'yesno', '1', 5); newpoints_add_setting('newpoints_shop_itemsprofile', 'newpoints_shop', 'Items on profile', 'Number of items to show in profile page. Set to 0 to disable this feature.', 'text', '5', 6); newpoints_add_setting('newpoints_shop_itemspostbit', 'newpoints_shop', 'Items on postbit', 'Number of items to show in postbit. Set to 0 to disable this feature.', 'text', '5', 7); $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_shop_categories` (\n\t `cid` bigint(30) UNSIGNED NOT NULL auto_increment,\n\t `name` varchar(100) NOT NULL default '',\n\t `description` text NOT NULL,\n\t `visible` smallint(1) NOT NULL default '1',\n\t `icon` varchar(255) NOT NULL default '',\n\t `usergroups` varchar(100) NOT NULL default '',\n\t `disporder` int(5) NOT NULL default '0',\n\t `items` int(10) NOT NULL default '0',\n\t `expanded` smallint(1) NOT NULL default '1',\n\t PRIMARY KEY (`cid`)\n\t\t) ENGINE=MyISAM"); $db->write_query("CREATE TABLE `" . TABLE_PREFIX . "newpoints_shop_items` (\n\t `iid` bigint(30) UNSIGNED NOT NULL auto_increment,\n\t `name` varchar(100) NOT NULL default '',\n\t `description` text NOT NULL,\n\t `price` DECIMAL(16,2) NOT NULL default '0',\n\t `icon` varchar(255) NOT NULL default '',\n\t `visible` smallint(1) NOT NULL default '1',\n\t `disporder` int(5) NOT NULL default '0',\n\t `infinite` smallint(1) NOT NULL default '0',\n\t `limit` smallint(1) NOT NULL default '0',\n\t `stock` int(10) NOT NULL default '0',\n\t `sendable` smallint(1) NOT NULL default '1',\n\t `sellable` smallint(1) NOT NULL default '1',\n\t `cid` int(10) NOT NULL default '0',\n\t `pm` text NOT NULL,\n\t PRIMARY KEY (`iid`)\n\t\t) ENGINE=MyISAM"); rebuild_settings(); }
/** * ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES * * _install(): * Called whenever a plugin is installed by clicking the "Install" button in the plugin manager. * If no install routine exists, the install button is not shown and it assumed any work will be * performed in the _activate() routine. * * function newpoints_hello_install() * { * } * * _is_installed(): * Called on the plugin management page to establish if a plugin is already installed or not. * This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE * if the plugin is not installed. * * function newpoints_hello_is_installed() * { * global $db; * if($db->table_exists("newpoints_hello_world")) * { * return true; * } * return false; * } * * _uninstall(): * Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin * from the installation (tables etc). If it does not exist, uninstall button is not shown. * * function newpoints_hello_uninstall() * { * } * * _activate(): * Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin * "visible" by adding templates/template changes, language changes etc. * */ function newpoints_hello_activate() { global $db, $mybb; // add settings // take a look at inc/plugins/newpoints.php to know exactly what each parameter means newpoints_add_setting('newpoints_hello_show', 'newpoints_hello', 'Show message', 'Set to yes if you want to show the hello message on every page.', 'yesno', 1, 1); rebuild_settings(); }