/** * Grant a user all privileges on a server. * @param int $sid * @param int $uid */ public static function grantAllToAll(Dog_Server $server, Dog_User $user, $bits = NULL) { $uid = $user->getID(); $all = $bits === NULL ? Dog_IRCPriv::allBits() : intval($bits); foreach (GDO::table('Dog_Channel')->selectColumn('chan_id', "chan_sid={$server->getID()}") as $cid) { if (false === self::table(__CLASS__)->insertAssoc(array('priv_cid' => $cid, 'priv_uid' => $uid, 'priv_privs' => $all))) { return false; } $user->setVar("dcp_{$cid}", $all); } return true; }
public static function getPermbits(Dog_Server $server, Dog_User $user, $needlogin = true) { $bits = $user->isRegistered() ? Dog_IRCPriv::REGBIT : 0; if ($needlogin && !$user->isLoggedIn()) { return $bits; } $uid = $user->getID(); $sid = $server->getID(); if (0 === ($bits = $user->getVarDefault("dsp_{$sid}", 0))) { $bits |= Dog_IRCPriv::LOGBIT; $bits |= self::table(__CLASS__)->selectVar('priv_privs', "priv_sid={$sid} AND priv_uid={$uid}"); # Cache if ($user->isHoster()) { $bits |= Dog_IRCPriv::HOSTBIT; } $user->setVar("dsp_{$sid}", $bits); } return $bits; }