Security Developers Guide

From Bebot Wiki 2
Jump to navigationJump to search

Expert use the Security System in your modules[edit]

The cache_mgr($action, $cache, $info, $more) function is used to add and remove information from the security cache. The advanced functions above all use the cache_mgr function to update information. If you are modifying the security database or roster directly in your module (something that in general should not be done) you must use the cache_mgr function to update the security cache as appropriate or your database modifications will not take effect until the bot is restarted.

Description of function parameters: $action: add or rem $cache: Which cache to modify (groups, guests, members, banned, groupmem, orgranks) $info: The information to add (or remove) $more: Extra information needed for some actions. (Optional Parameter)

 * Add and remove a guest:

$this -> cache_mgr("add", "guests", "Glarawyn"); $this -> cache_mgr("rem", "guests", "Glarawyn");

 * Add and remove a member:

$this -> cache_mgr("add", "members", "Glarawyn"); $this -> cache_mgr("rem", "members", "Glarawyn");

 * Add and remove a ban:

$this -> cache_mgr("add", "banned", "Glarawyn"); $this -> cache_mgr("rem", "banned", "Glarawyn");

 * Add a group: 

$tmp = array("gid" => "10", "name" => "groupname", "description" = "Example Group", "access_level" => 2); $this -> cache_mgr("add", "groups", $tmp);

 * Remove a group: 

$this -> cache_mgr("rem", "groups", $groupname);

 * Add and remove a group member:

$this -> cache_mgr("add", "groupmem", $groupname, $membername); $this -> cache_mgr("rem", "groupmem", $groupname, $membername);

 * Change an org rank's access level:

$this -> cache_mgr("add", "orgrank", "President", "255");