Exemplo n.º 1
0
function rollTags()
{
    assertStringArg('sum', TRUE);
    assertUIntArg('realsum');
    if ($_REQUEST['sum'] != $_REQUEST['realsum']) {
        showFuncMessage(__FUNCTION__, 'ERR');
        return;
    }
    // Even if the user requested an empty tag list, don't bail out, but process existing
    // tag chains with "zero" extra. This will make sure, that the stuff processed will
    // have its chains refined to "normal" form.
    $extratags = isset($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
    $n_ok = 0;
    // Minimizing the extra chain early, so that tag rebuilder doesn't have to
    // filter out the same tag again and again. It will have own noise to cancel.
    $extrachain = getExplicitTagsOnly(buildTagChainFromIds($extratags));
    foreach (listCells('rack', getBypassValue()) as $rack) {
        if (rebuildTagChainForEntity('rack', $rack['id'], $extrachain)) {
            $n_ok++;
        }
        amplifyCell($rack);
        foreach ($rack['mountedObjects'] as $object_id) {
            if (rebuildTagChainForEntity('object', $object_id, $extrachain)) {
                $n_ok++;
            }
        }
    }
    showFuncMessage(__FUNCTION__, 'OK', array($n_ok));
}
Exemplo n.º 2
0
function renderCell($cell)
{
    switch ($cell['realm']) {
        case 'user':
            echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
            printImageHREF('USER');
            echo '</td><td>' . mkA($cell['user_name'], 'user', $cell['user_id']) . '</td></tr>';
            if (strlen($cell['user_realname'])) {
                echo "<tr><td><strong>" . niftyString($cell['user_realname']) . "</strong></td></tr>";
            } else {
                echo "<tr><td class=sparenetwork>no name</td></tr>";
            }
            echo '<td>';
            if (!isset($cell['etags'])) {
                $cell['etags'] = getExplicitTagsOnly(loadEntityTags('user', $cell['user_id']));
            }
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo "</td></tr></table>";
            break;
        case 'file':
            echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
            switch ($cell['type']) {
                case 'text/plain':
                    printImageHREF('text file');
                    break;
                case 'image/jpeg':
                case 'image/png':
                case 'image/gif':
                    printImageHREF('image file');
                    break;
                default:
                    printImageHREF('empty file');
                    break;
            }
            echo "</td><td>";
            echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'file', $cell['id']);
            echo "</td><td rowspan=3 valign=top>";
            if (isset($cell['links']) and count($cell['links'])) {
                printf("<small>%s</small>", serializeFileLinks($cell['links']));
            }
            echo "</td></tr><tr><td>";
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo '</td></tr><tr><td>';
            if (isolatedPermission('file', 'download', $cell)) {
                // FIXME: reuse renderFileDownloader()
                echo "<a href='?module=download&file_id={$cell['id']}'>";
                printImageHREF('download', 'Download file');
                echo '</a>&nbsp;';
            }
            echo formatFileSize($cell['size']);
            echo "</td></tr></table>";
            break;
        case 'ipv4vs':
        case 'ipvs':
        case 'ipv4rspool':
            renderSLBEntityCell($cell);
            break;
        case 'ipv4net':
        case 'ipv6net':
            echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
            printImageHREF('NET');
            echo '</td><td>' . mkA("{$cell['ip']}/{$cell['mask']}", $cell['realm'], $cell['id']);
            echo getRenderedIPNetCapacity($cell);
            echo '</td></tr>';
            echo "<tr><td>";
            if (strlen($cell['name'])) {
                echo "<strong>" . niftyString($cell['name']) . "</strong>";
            } else {
                echo "<span class=sparenetwork>no name</span>";
            }
            // render VLAN
            renderNetVLAN($cell);
            echo "</td></tr>";
            echo '<tr><td>';
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo "</td></tr></table>";
            break;
        case 'rack':
            echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
            $thumbwidth = getRackImageWidth();
            $thumbheight = getRackImageHeight($cell['height']);
            echo "<img border=0 width={$thumbwidth} height={$thumbheight} title='{$cell['height']} units' ";
            echo "src='?module=image&img=minirack&rack_id={$cell['id']}'>";
            echo "</td><td>";
            echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'rack', $cell['id']);
            echo "</td></tr><tr><td>";
            echo niftyString($cell['comment']);
            echo "</td></tr><tr><td>";
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo "</td></tr></table>";
            break;
        case 'location':
            echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
            printImageHREF('LOCATION');
            echo "</td><td>";
            echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'location', $cell['id']);
            echo "</td></tr><tr><td>";
            echo niftyString($cell['comment']);
            echo "</td></tr><tr><td>";
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo "</td></tr></table>";
            break;
        case 'object':
            echo "<table class='slbcell vscell'><tr><td rowspan=2 width='5%'>";
            printImageHREF('OBJECT');
            echo '</td><td>';
            echo mkA('<strong>' . niftyString($cell['dname']) . '</strong>', 'object', $cell['id']);
            echo '</td></tr><tr><td>';
            echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : '&nbsp;';
            echo "</td></tr></table>";
            break;
        default:
            throw new InvalidArgException('realm', $cell['realm']);
    }
}
Exemplo n.º 3
0
function produceTagsForNewRecord($realm, $tagidlist, $record_id)
{
    foreach (getExplicitTagsOnly(buildTagChainFromIds($tagidlist)) as $taginfo) {
        addTagForEntity($realm, $record_id, $taginfo['id']);
    }
}
function renderMyAccount()
{
    global $remote_username, $remote_displayname, $expl_tags, $impl_tags, $auto_tags;
    startPortlet('Current user info');
    echo '<div style="text-align: left; display: inline-block;">';
    echo "<table>";
    echo "<tr><th>Login:</th><td>{$remote_username}</td></tr>\n";
    echo "<tr><th>Name:</th><td>{$remote_displayname}</td></tr>\n";
    echo "<tr><th>Explicit tags:</th><td>" . serializeTags(getExplicitTagsOnly($expl_tags)) . "</td></tr>\n";
    echo "<tr><th>Implicit tags:</th><td>" . serializeTags($impl_tags) . "</td></tr>\n";
    echo "<tr><th>Automatic tags:</th><td>" . serializeTags($auto_tags) . "</td></tr>\n";
    echo '</table></div>';
}