This is an outline of the framework provided by MyPlaza to module developers. The MyPlaza framework adds a number of features, on top of what MyBB offers to plugin developers. These include:
$pm variable, as an array. The optional $touser is an array containing the details of the user to send the PM to (retrievable via the get_user function). It is recommended that you set the $touser variable, however, if it is not set, MyPlaza will try to determine the array from details in the PM.
$pm array should have, at minimum, elements with the keys 'subject' and 'message'; you may set additional parameters if need be.
myplaza_send_pm(array( 'subject' => 'My PM', 'message' => 'This is a PM!' ), get_user(1));
output_page() function, however, this is specifically designed for AJAX. The function will automatically convert any character encodings if necessary, and will output all necessary headers, run shutdown functions, and GZips the output if appropriate.
$type variable just specifies what is sent in the Content-type header - by default, it's text/html however, if you want text/plain, set the $type variable to plain.
$db->show_fields_from function. All this does is set it up so that the keys of the array returned are the field names.
TABLE_PREFIX.
TABLE_PREFIX.
$table (do not send TABLE_PREFIX). $rows is basically an array of rows to add. This is similar to sending each row to $db->insert_query however, this function tends to run faster since it combines most of these queries into a single one.
$rows should have the same fields. If they don't, you can supply true to the $check_all parameter (this causes all rows to be checked and filled in appropriately). Supplying true to the optional $escape parameter causes all values in the array to be escaped via $db->escape_string.
db_insert_rows function above, by allowing multiple insert calls to be summed up into the least number of queries possible. It is recommended that you should use this function to insert rows into the DB, unless you really need the rows to be inserted immediately (you generally don't).
$db->update_query on each row in the $rows array, however, this typically runs faster for larger updates. If the update set is large enough, a single INSERT INTO ... ON DUPLICATE KEY UPDATE query is executed, effectively doing all updates in a single query.
$rows array, you should send an array of rows to update, with keys of the array being the primary key, or a unique key of the table. Specify which key you have used in the $key variable. Note that this will not work with composite primary, or composite unique keys. If no $key is specified, the function will query for the primary key, which is what will be assumed (if the primary key is found to be composite, the function will die). Note that each row must have exactly the same fields.
$updateExpr is a powerful switch, allowing you to specify a custom expression, rather than update with the specified value. Use {$values['fieldname']} in the string to represent the specified value. To help illustrate this, we'll take an example - let's say you want to increase the postcount of UID #1's money by 10, UID #2's money by 50, and UID #10's money by 5...etc, and set various values for their reputation - you can use the following statement: $update_rows = array(
1 => array('postnum' => 10, 'reputation' => 5),
2 => array('postnum' => 50, 'reputation' => 1),
10 => array('postnum' => 5, 'reputation' => 10),
12 => array('postnum' => -2, 'reputation' => 90),
50 => array('postnum' => 0, 'reputation' => 0),
25 => array('postnum' => 1, 'reputation' => 1),
);
db_update_rows('users', $update_rows, 'uid', false,
'postnum=postnum+{$values[\'postnum\']}, reputation={$values[\'reputation\']}');db_shutdown_insert_rows this function will execute db_update_rows at shutdown, allowing faster update speed. Note that only one $key may be specified for each table which is to be updated.
$db->simple_select function (also offers more than MyBB's $db->select function). This function is fully backwards compatible with $db->simple_select. Additional functionality include:
$tables parameter$options array; these are distinction (set to DISTINCT to select distinct rows only), group_by (specify the fields to group by) and having (the HAVING clause)$returnQuery parameter - if set to true, will return the query to be executed, rather than execute the query. Useful if you need to send the query to db_create_table$db->update_query, however, doesn't escape values, so you can perform update queries involving expressions.
auto_increment value of the specified table.
$helpdoc parameter can be used to specify any additional information. If the parameter is not supplied, MyPlaza will use MyBB's translation $lang variables.
$lang->help_myplaza_modulename_name, $lang->help_myplaza_modulename_desc, and $lang->help_myplaza_modulename_document, where modulename is the filename of the module.
add_helpdoc. If you specified a custom ID when adding the helpdoc, make sure you specify it here too.
$new_templates is an array of the templates to insert, where the keys of the array are the template names. By default, the templates are inserted at shutdown. If, for some odd reason, you need to insert them immediately, set $immediate to true.
find_replace_templatesets function. You can use the str_replace function, by specifying that in the $method variable, rather than the default preg_replace method.
$lang->setting_settingname and $lang->setting_settingname_desc respectively (where settingname is the name of the setting to be added).
included on each page load (which can reduce page generation times).
$tables can be an array of tables to drop, or just a single table. Again, do not send TABLE_PREFIX.
$columns is just an array of field names to be dropped.
$fieldname from a table, based on information supplied in the $info array. Supply the field information in the $info array.
$iid (note, if you have a global variable $item, this function will use that instead of querying for the item details). The optional $cost variable is only used for verification purposes, ie, if a displayed cost differs to the one stored in the DB, an error will be generated. Set $visibleOverride to true if you want the item to be purchased even if the user cannot see the item in the plaza.
true if the buying is successful, or false otherwise.
$extraRate parameter.
calcStock function - it calculates the stock offset to store in the DB.
$itemname, with the supplied format string (which must contain {name} as the placeholder), $itemformat.
$item array argument. You may need to supply a $module argument, specifying the name of the module, depending on where you call this function.
_lang() and/or _lang_admin() functions of a module, into the $lang object. Basically the equivalent of $lang->load() but for modules.
$cid and returns it as an array.
$iid and returns it as an array.
$iids.
$module if you call this function at certain places).
exit command, as, due to the number of functions which run at shutdown, this may be required to get things to work.
$user and the amount to add in $amount. You can also include an extra $rate to multiply by. If you want the update to be performed immediately, rather than at shutdown, set $immediate to true.
$ugroup is a part of $visiblegroups; used for determining if something is visible to a certain usergroup.
find_replace_templatesets(). This function is included as convenience, as you don't have to include /inc/adminfunctions_templates.php each time you want to use it. Also, this provides an extra $method, so you can use str_replace instead of preg_replace. Also allows the user to specify different template replacement strategies.
elemId, the initial alpha, the rate at which to perform the fade (alpha is increased at this rate per 0.05 seconds), the final alpha value to achieve (targetAlpha) and a function to execute when the animation is complete (completeFunc).
fadeInElement but increases transparency instead of decreasing it.
value is the opacity level, from 0 (transparent) to 1 (opaque).
formObj so that MyPlaza can build the AJAX request by reading the form values.
xmlhttpAction is sent, via AJAX, with the contents of all the elements of the form sent as the postBody. submitElem and newVal are really provided for your convenience (and may be removed later) since most of the time, you'll make use of them. submitElem should point to the submit button in your form, and newVal is the text that submitElem should be changed to (MyPlaza will also disable the submitElem button during AJAX processing). messageId should be the ID of the DIV/SPAN (or whatever) HTML element where the returned message is displayed. completeFunc is simply the function that is executed once buying is complete and successful.
admin_users_add_code hook, but for editing a user.
admin_users_add_code hook, but for adding a usergroup.
admin_users_edit_code hook, but for editing a usergroup.
$replacement variable to do this.