PermissionModel::_UnpivotPermissionsRow PHP Method

_UnpivotPermissionsRow() protected method

protected _UnpivotPermissionsRow ( $Row, &$Result, boolean $IncludeRole = false )
$Row
$Result
$IncludeRole boolean
    protected function _UnpivotPermissionsRow($Row, &$Result, $IncludeRole = false)
    {
        $GlobalName = val('Name', $Row);
        // Loop through each permission in the row and place them in the correct place in the grid.
        foreach ($Row as $PermissionName => $Value) {
            list($Namespace, $Name, $Suffix) = self::SplitPermission($PermissionName);
            if (empty($Name)) {
                continue;
                // was some other column
            }
            if ($GlobalName) {
                $Namespace = $GlobalName;
            }
            if (array_key_exists('JunctionTable', $Row) && ($JunctionTable = $Row['JunctionTable'])) {
                $Key = "{$JunctionTable}/{$Row['JunctionColumn']}/{$Row['JunctionID']}" . ($IncludeRole ? '/' . $Row['RoleID'] : '');
            } else {
                $Key = '_' . $Namespace;
            }
            // Check to see if the namespace is in the result.
            if (!array_key_exists($Key, $Result)) {
                $Result[$Key] = array('_Columns' => array(), '_Rows' => array(), '_Info' => array('Name' => $Namespace));
            }
            $NamespaceArray =& $Result[$Key];
            // Add the names to the columns and rows.
            $NamespaceArray['_Columns'][$Suffix] = true;
            $NamespaceArray['_Rows'][$Name] = true;
            // Augment the value depending on the junction ID.
            if (substr($Key, 0, 1) === '_') {
                $PostValue = $PermissionName;
            } else {
                $PostValue = $Key . '//' . $PermissionName;
            }
            $NamespaceArray[$Name . '.' . $Suffix] = array('Value' => $Value, 'PostValue' => $PostValue);
        }
    }