Changeset 1355

Show
Ignore:
Timestamp:
06/14/08 22:12:23 (2 months ago)
Author:
benoitg
Message:
  • Add NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL permission. User is allowed to exceed dynamic abuse control limits at this node.
  • Stakeholder selector UI tweaks
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1352 r1355  
    11# $Id$ 
     22008-06-12 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3        * Add NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL permission.  User is allowed to exceed dynamic abuse control limits at this node. 
     4        * Stakeholder selector UI tweaks 
     5 
    262008-06-12 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
    37        * Use bigint for dynamic abuse control byte values 
  • trunk/wifidog-auth/wifidog/classes/Content/UIAllowedBandwidth/UIAllowedBandwidth.php

    r1354 r1355  
    9090    } 
    9191    /* Format human readable filesize */ 
    92     static function formatSize($size, $round = 0) { 
     92    static public function formatSize($size, $round = 0) { 
    9393        //Size must be bytes! 
    9494        $sizes = array(_('B'), _('kB'), _('MB'), _('GB'), _('TB'), _('PB'), _('EB'), _('ZB'), _('YB')); 
  • trunk/wifidog-auth/wifidog/classes/Permission.php

    r1351 r1355  
    105105             
    106106            $PERMISSIONS['NODE_PERM_EDIT_CONFIG'] = array(_("TEMPORARY:  User is allowed to edit general configuration for this node.  This will be replaced with more granular permissions in the future"), StakeholderType::Node, false); 
    107  
     107            $PERMISSIONS['NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL'] = array(_("User is allowed to exceed dynamic abuse control limits at this node"), StakeholderType::Node, false); 
     108             
    108109            self::$_permissionArray = $PERMISSIONS; 
    109110        } 
  • trunk/wifidog-auth/wifidog/classes/Role.php

    r1339 r1355  
    145145        !empty($userData['stakeholderTypeId'])?$targetObjectClassSql = " AND stakeholder_type_id = '".$db->escapeString($userData['stakeholderTypeId'])."' ":$targetObjectClassSql=null; 
    146146 
    147         $sql = "SELECT role_id, stakeholder_type_id FROM roles WHERE 1=1 $targetObjectClassSql ORDER BY stakeholder_type_id, role_id"; 
     147        $sql = "SELECT role_id, role_description_content_id, stakeholder_type_id FROM roles WHERE 1=1 $targetObjectClassSql ORDER BY stakeholder_type_id, role_id"; 
    148148        $role_rows = null; 
    149149        $db->execSql($sql, $role_rows, false); 
     
    155155                $i = 0; 
    156156                foreach ($role_rows as $role_row) { 
     157                    $role = self::getObject($role_row['role_id']); 
    157158                    $tab[$i][0] = $role_row['role_id']; 
    158159                    empty($userData['stakeholderTypeId'])?$tab[$i][1]=$role_row['stakeholder_type_id'].'; ':$tab[$i][1]=null; 
    159                     $tab[$i][1] .= $role_row['role_id']; 
     160                     
     161                    $tab[$i][1] .= $role->getLabelStr(); 
    160162                    $i ++; 
    161163                } 
     
    176178    } 
    177179 
     180    function getLabelStr() { 
     181        if($this->_row['role_description_content_id']) { 
     182            $description = Content::getObject($this->_row['role_description_content_id'])->__toString() . ' '; 
     183        } 
     184        else { 
     185            $description = null; 
     186        } 
     187        return sprintf("%s (%s) ", $description, $this->id); 
     188    } 
    178189 
    179190    /** 
     
    329340        array ( 
    330341        'isSimpleContent' 
    331                        
     342       
    332343        ); 
    333344        $description_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 
     
    472483    public function delete(& $errmsg) 
    473484    { 
    474                  
     485 
    475486        $retval = false; 
    476487        if (Security::hasPermission('SERVER_PERM_EDIT_ROLES', Server::getServer())) { 
     
    502513            'title' => _("User roles"), 
    503514            'url' => BASE_URL_PATH.htmlspecialchars("admin/generic_object_admin.php?object_class=Role&action=list") 
    504                ); 
     515            ); 
    505516        } 
    506517        return $items; 
  • trunk/wifidog-auth/wifidog/classes/Stakeholder.php

    r1316 r1355  
    8383                foreach ($stakeholder_rows as $stakeholder_row) { 
    8484                    $user = User::getObject($stakeholder_row['user_id']); 
    85                     if(!empty($stakeholder_row['role_description'])) { 
    86                         $title = htmlspecialchars($stakeholder_row['role_description']); 
    87                         $roleStr = "<a href='#' title='$title'>".$stakeholder_row['role_id'] ."</a>\n"; 
    88                     } 
    89                     else { 
    90                         $roleStr = $stakeholder_row['role_id']; 
    91                     } 
     85                    $role = Role::getObject($stakeholder_row['role_id']); 
     86                    $roleStr = htmlspecialchars($role->getLabelStr()); 
    9287                    $name = $object_id . "_stakeholder_" . $stakeholder_row['user_id'] . "_". $stakeholder_row['role_id'] . "_remove"; 
    9388                    $listDataContents = InterfaceElements::generateAdminSection("", $user->getListUI() . ' '. $roleStr, InterfaceElements::generateInputSubmit($name, _("Remove stakeholder"))); 
  • trunk/wifidog-auth/wifidog/classes/StakeholderType.php

    r1249 r1355  
    111111        $i = 0; 
    112112        foreach ($rows as $row) { 
     113             
    113114            $tab[$i][0] = $row['stakeholder_type_id']; 
    114115            $tab[$i][1] = $row['stakeholder_type_id']; 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1351 r1355  
    587587        $abuseControlReport = self::getAbuseControlConnectionHistory($user, $mac, $node); 
    588588        if($abuseControlReport) { 
     589            if (!$user) { 
     590                $user = User::getCurrentUser(); 
     591            } 
    589592            //pretty_print_r($abuseControlReport); 
    590  
    591             if($abuseControlReport['network_total_bytes_exceeded_limit']=='t') { 
    592                 $retval .= sprintf(_("During the last %s period, you transfered %d bytes throughout the network, which exceeds the %d bytes limit."), $abuseControlReport['connection_limit_window'], $abuseControlReport['network_total_bytes'], $abuseControlReport['connection_limit_network_max_total_bytes']); 
    593             } 
    594             if($abuseControlReport['node_total_bytes_exceeded_limit']=='t') { 
    595                 $retval .= sprintf(_("During the last %s period, you transfered %d bytes at this node, which exceeds the %d bytes limit."), $abuseControlReport['connection_limit_window'], $abuseControlReport['node_total_bytes'], $abuseControlReport['connection_limit_node_max_total_bytes']); 
    596             } 
    597             if($abuseControlReport['network_duration_exceeded_limit']=='t') { 
    598                 $retval .= sprintf(_("During the last %s period, you were online for a duration of %s throughout the network, which exceeds the %s limit."), $abuseControlReport['connection_limit_window'], $abuseControlReport['network_duration'], $abuseControlReport['connection_limit_network_max_usage_duration']); 
    599             } 
    600             if($abuseControlReport['node_duration_exceeded_limit']=='t') { 
    601                 $retval .= sprintf(_("During the last %s period, you were online for a duration of %s at this node, which exceeds the %s limit."), $abuseControlReport['connection_limit_window'], $abuseControlReport['node_duration'], $abuseControlReport['connection_limit_node_max_usage_duration']); 
     593            if($node && Security::hasPermission(Permission::P('NODE_PERM_BYPASS_DYNAMIC_ABUSE_CONTROL'), $node, $user)) { 
     594                $retval = false; 
     595            } 
     596            else { 
     597                require_once('classes/Content/UIAllowedBandwidth/UIAllowedBandwidth.php'); 
     598                if($abuseControlReport['network_total_bytes_exceeded_limit']=='t') { 
     599                    $retval .= sprintf(_("During the last %s period, you transfered %s bytes throughout the network, which exceeds the %s bytes limit for the entire network."), $abuseControlReport['connection_limit_window'], UIAllowedBandwidth::formatSize($abuseControlReport['network_total_bytes']), UIAllowedBandwidth::formatSize($abuseControlReport['connection_limit_network_max_total_bytes'])); 
     600                } 
     601                if($abuseControlReport['node_total_bytes_exceeded_limit']=='t') { 
     602                    $retval .= sprintf(_("During the last %s period, you transfered %s bytes at this node, which exceeds the %s bytes limit for this node."), $abuseControlReport['connection_limit_window'], UIAllowedBandwidth::formatSize($abuseControlReport['node_total_bytes']), UIAllowedBandwidth::formatSize($abuseControlReport['connection_limit_node_max_total_bytes'])); 
     603                } 
     604                if($abuseControlReport['network_duration_exceeded_limit']=='t') { 
     605                    $retval .= sprintf(_("During the last %s period, you were online for a duration of %s throughout the network, which exceeds the %s limit for the entire network."), $abuseControlReport['connection_limit_window'], $abuseControlReport['network_duration'], $abuseControlReport['connection_limit_network_max_usage_duration']); 
     606                } 
     607                if($abuseControlReport['node_duration_exceeded_limit']=='t') { 
     608                    $retval .= sprintf(_("During the last %s period, you were online for a duration of %s at this node, which exceeds the %s limit for this node."), $abuseControlReport['connection_limit_window'], $abuseControlReport['node_duration'], $abuseControlReport['connection_limit_node_max_usage_duration']); 
     609                } 
    602610            } 
    603611        }