function print_channel_permission_rows($customword, $channelpermission = array(), $extra = '')
{
    global $vbphrase;
    print_label_row("<b>{$customword}</b>", '
		<input type="button" class="button" value="' . $vbphrase['all_yes'] . '" onclick="' . iif($extra != '', 'if (js_set_custom()) { ') . ' js_check_all_option(this.form, 1);' . iif($extra != '', ' }') . '" class="button" />
		<input type="button" class="button" value=" ' . $vbphrase['all_no'] . ' " onclick="' . iif($extra != '', 'if (js_set_custom()) { ') . ' js_check_all_option(this.form, 0);' . iif($extra != '', ' }') . '" class="button" />
		<!--<input type="submit" class="button" value="Okay" class="button" />-->
	', 'tcat', 'middle');
    // Load permissions
    require_once DIR . '/includes/class_bitfield_builder.php';
    $bitvalues = array('forumpermissions', 'forumpermissions2', 'moderatorpermissions', 'createpermissions');
    $permFields = vB_ChannelPermission::fetchPermFields();
    $permPhrases = vB_ChannelPermission::fetchPermPhrases();
    if (empty($channelpermission)) {
        // we need the defaults to be displayed
        $channelpermission = vB_ChannelPermission::instance()->fetchPermissions(1);
        $channelpermission = current($channelpermission);
    }
    foreach ($permFields as $permField => $type) {
        //Do the non-bitmap fields first.
        switch ($type) {
            case vB_ChannelPermission::TYPE_HOURS:
            case vB_ChannelPermission::TYPE_COUNT:
                $permvalue = $channelpermission[$permField];
                print_input_row($vbphrase[$permPhrases[$permField]], $permField, $permvalue, true, 35, 0, '', false, 'channelPerm_' . $permField);
                break;
            case vB_ChannelPermission::TYPE_BOOL:
                $permvalue =& $channelpermission[$permField];
                print_yes_no_row($vbphrase[$permPhrases[$permField]], $permField, $permvalue, $extra);
                break;
        }
    }
    //now do the bitmaps
    foreach ($permFields as $permField => $type) {
        if ($type == vB_ChannelPermission::TYPE_BITMAP) {
            if ($permField !== 'forumpermissions2') {
                print_table_header($vbphrase[$permPhrases[$permField]]);
            }
            foreach ($channelpermission['bitfields'][$permField] as $permBit) {
                if ($permBit['used']) {
                    if (empty($permBit['phrase']) and $permField == 'moderatorpermissions') {
                        $permBit['phrase'] = "moderator_add_edit_" . $permBit['name'] . "_title";
                    }
                    if ($permField == 'moderatorpermissions' and $permBit['name'] == 'canopenclose') {
                        $helpOptions = array('prefix' => $permField);
                    } else {
                        $helpOptions = array();
                    }
                    print_yes_no_row(isset($vbphrase[$permBit['phrase']]) ? $vbphrase[$permBit['phrase']] : $permBit['phrase'], $permField . '[' . $permBit['name'] . ']', $permBit['set'], $extra, $helpOptions);
                }
            }
        }
    }
    // Legacy Hook 'admin_nperms_form' Removed //
}
 public function getChannelPerm($usergroupid, $permissiongroup, $permission, $channelid)
 {
     if ($permissiongroup == 'moderatorpermissions') {
         $bf_ugp = $this->datastore->getValue('bf_misc_' . $permissiongroup);
     } else {
         $bf_ugp = $this->datastore->getValue('bf_ugp_' . $permissiongroup);
     }
     if (!isset($this->channelPermissions[$usergroupid])) {
         $this->loadChannelPermissions($usergroupid);
         $this->validateInfractionPermissions($usergroupid, $channelid);
     }
     if (empty($this->permissionsFrom)) {
         $this->permissionsFrom = vB::getDatastore()->getValue('vBUgChannelPermissionsFrom');
     }
     // We might have gotten an integer;
     if (is_numeric($permission)) {
         $permission = strtolower(vB_Types::instance()->getContentTypePackage($permission) . '_' . vB_Types::instance()->getContentTypeClass($permission));
     } else {
         $permission = strtolower($permission);
     }
     if (!isset($this->channelPermissions[$usergroupid][$channelid]) and isset($this->permissionsFrom[$usergroupid]) and isset($this->permissionsFrom[$usergroupid][$channelid])) {
         $channelid = $this->permissionsFrom[$usergroupid][$channelid];
     }
     if (isset($bf_ugp[$permission]) and isset($this->channelPermissions[$usergroupid][$channelid])) {
         switch ($permissiongroup) {
             case 'forumpermissions':
                 return $bf_ugp[$permission] & $this->channelPermissions[$usergroupid][$channelid]['forumpermissions'];
                 break;
             case 'forumpermissions2':
                 return $bf_ugp[$permission] & $this->channelPermissions[$usergroupid][$channelid]['forumpermissions2'];
                 break;
             case 'createpermissions':
                 //We might have gotten an integer;
                 if (is_numeric($permission)) {
                     $permission = strtolower(vB_Types::instance()->getContentTypePackage($permission) . '_' . vB_Types::instance()->getContentTypeClass($permission));
                 } else {
                     $permission = strtolower($permission);
                 }
                 return $bf_ugp[$permission] & $this->channelPermissions[$usergroupid][$channelid]['createpermissions'];
                 break;
             case 'moderatorpermissions':
                 if ($usergroupid == 1) {
                     return false;
                 }
                 return $bf_ugp[$permission] & intval($this->channelPermissions[$usergroupid][$channelid]['moderatorpermissions']);
                 break;
             default:
                 return false;
         }
         // switch
     } else {
         $permFields = vB_ChannelPermission::fetchPermFields();
         if (isset($permFields[$permission]) and $permFields[$permission] != vB_ChannelPermission::TYPE_BITMAP and isset($this->channelPermissions[$usergroupid][$channelid])) {
             return $this->channelPermissions[$usergroupid][$channelid][$permission];
         }
         return false;
     }
 }