Skip to content

Instantly share code, notes, and snippets.

@DivinityArcane
Last active December 14, 2015 05:48
Show Gist options
  • Save DivinityArcane/5037496 to your computer and use it in GitHub Desktop.
Save DivinityArcane/5037496 to your computer and use it in GitHub Desktop.
<?php
function add_privs($ns, $user, $privs, $sort = true) {
if (!in_array($user, $this->bdschannel[$ns]['privs'][$privs])) {
array_push($this->bdschannel[$ns]['privs'][$privs], $user);
if ($sort)
ksort($this->bdschannel[$ns]['privs'][$privs]);
}
}
function remove_privs($ns, $user, $sort = true) {
foreach ($this->bdschannel[$ns]['privs'] as $priv => $arr) {
if (in_array($user, $arr)) {
unset($this->bdschannel[$ns]['privs'][$priv][array_search($user, $arr)]);
if ($sort)
ksort($this->bdschannel[$ns]['privs'][$priv]);
}
}
}
function change_privs($ns, $user, $privs, $sort = true) {
$this->remove_privs($ns, $user, $sort);
$this->add_privs($ns, $user, $privs, $sort);
}
function check_privs($ns, $user, $privs) {
return in_array($user, $this->bdschannel[$ns]['privs'][$privs]);
}
function get_privs($ns, $user) {
foreach ($this->bdschannel[$ns]['privs'] as $priv => $arr) {
if (in_array($user, $arr)) {
return $priv;
}
}
return -1;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment