Functions
I've included a set of functions to help developers with development, and some of them are required if they want to avoid writing 10 lines of code for adding each setting, for example.
NewPoints comes with a hello world plugin based off MyBB's one as the code is nearly the same. Can be found in inc/plugins/newpoints
- newpoints_remove_templates($templates = '')
- Deletes templates from the database
- @param string a list of templates seperated by ',' e.g. 'test','test_again','testing'
- @param bool false if something went wrong
- newpoints_add_template($name = '', $contents = '', $sid = -1)
- Adds a new template
- @param string the title of the template
- @param string the contents of the template
- @param integer the sid of the template
- @param bool false if something went wrong
- newpoints_remove_settings($settings = '')
- Deletes settings from the database
- @param string a list of settings seperated by ',' e.g. 'test','test_again','testing'
- @param bool false if something went wrong
- newpoints_add_setting($name = '', $plugin = '', $title = '', $description = '', $type = '', $value = '', $disporder = 0)
- Adds a new setting
- @param string the name (unique identifier) of the setting
- @param string the codename of plugin which owns the setting ('main' for main setting)
- @param string the title of the setting
- @param string the description of the setting
- @param string the type of the setting ('text', 'textarea', etc...)
- @param string the value of the setting
- newpoints_addpoints($uid, $points, $forumrate = 1, $grouprate = 1, $isstring = false)
- Adds/Subtracts points to a user
- @param integer the id of the user
- @param float the number of points to add or subtract (if a negative value)
- @param integer the forum income rate
- @param integer the user group income rate
- @param bool if the uid is a string in case we don't have the uid we can update the points field by searching for the user name
- newpoints_getrules($type = '', $id = 0)
- Get rules of a certain group or forum
- @param string the type of rule: 'forum' or 'group'
- @param integer the id of the group or forum
- @return bool false if something went wrong
- newpoints_getallrules($type = '')
- Get all rules
- @param string the type of rule: 'forum' or 'group'
- @return array containing all rules
- newpoints_format_points($points)
- Formats points according to the settings
- @param float the amount of points
- @return string formated points
- newpoints_send_pm($pm, $fromid = 0)
- Sends a PM to a user
- @param array: The PM to be sent; should have 'subject', 'message', 'touid' and 'receivepms' (receivepms is for admin override in case the user has disabled pm's)
- @param int: from user id (0 if you want to use the uid of the person that sends it. -1 to use MyBB Engine
- @return bool: true if PM sent
- newpoints_getuser_byname($username = '', $fields = '*')
- Get the user data of a user name
- @param string the user name
- @param string the fields to fetch
- @return array the user data
- newpoints_get_usergroup($gid = 0)
- Get the user group data of the gid
- @param string the user name
- @param string the fields to fetch
- @return array the user data
- function newpoints_log($action='', $data = '', $username = '', $uid = 0)
- Create a new log entry
- @param string action taken
- @param string extra data
- @param username of who's executed the action
- @param uid of who's executed the action
- @return bool false if something went wrong
- function newpoints_remove_log($action=array())
- Removes all log entries based on action
- @param array action taken
- function newpoints_find_replace_templatesets($action=array())
- Find and replace a string in a particular template in global templates set
- @param string The name of the template
- @param string The regular expression to match in the template
- @param string The replacement string
- @return bolean true if matched template name, false if not.
Support
If you have any questions, ask them at MyBB-Plugins.com.