Esempio n. 1
0
function editUserProperties()
{
    $taglist = genericAssertion('taglist', 'array0');
    $user_id = getBypassValue();
    rebuildTagChainForEntity('user', $user_id, buildTagChainFromIds($taglist), TRUE);
    $user = spotEntity('user', $user_id);
    print_r($user);
    showFuncMessage(__FUNCTION__, 'OK', array($user['user_name']));
}
Esempio n. 2
0
function rollTags()
{
    assertStringArg('sum', TRUE);
    assertUIntArg('realsum');
    if ($_REQUEST['sum'] != $_REQUEST['realsum']) {
        return showFuncMessage(__FUNCTION__, 'ERR');
    }
    // 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++;
            }
        }
    }
    return showFuncMessage(__FUNCTION__, 'OK', array($n_ok));
}
Esempio n. 3
0
File: api.php Progetto: xtha/salt
     $dbxlink->commit();
     // redirect to the get_object URL for the edited object
     redirectUser($_SERVER['SCRIPT_NAME'] . "?method=get_object&object_id={$object_id}");
     break;
     // update user-defined tags for an object
     //    UI equivalent: /index.php?module=redirect&page=object&tab=tags&op=saveTags
     //    UI handler: saveEntityTags()
 // update user-defined tags for an object
 //    UI equivalent: /index.php?module=redirect&page=object&tab=tags&op=saveTags
 //    UI handler: saveEntityTags()
 case 'update_object_tags':
     require_once 'inc/init.php';
     genericAssertion('object_id', 'uint0');
     $tags = isset($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
     $num_tags = count($tags);
     rebuildTagChainForEntity('object', $_REQUEST['object_id'], buildTagChainFromIds($tags), TRUE);
     sendAPIResponse(array(), array('message' => 'updated tags successfully', 'object_id' => $_REQUEST['object_id'], 'num_tags' => $num_tags));
     break;
     // sync a switch or PDU's ports using SNMP
     //    UI equivalent: /index.php?module=redirect&page=object&tab=snmpportfinder
     //    UI handler: querySNMPData()
 // sync a switch or PDU's ports using SNMP
 //    UI equivalent: /index.php?module=redirect&page=object&tab=snmpportfinder
 //    UI handler: querySNMPData()
 case 'snmp_sync_object':
     require_once 'inc/init.php';
     require_once 'inc/snmp.php';
     global $log_messages;
     genericAssertion('object_id', 'uint0');
     genericAssertion('ver', 'uint');
     $object_id = $_REQUEST['object_id'];
Esempio n. 4
0
function addTagToObject($facter, $newmachine)
{
    $tags = array($facter['machinetype'], $facter['domain']);
    $count_tags = count($tags);
    for ($i = 0; $i < $count_tags; $i++) {
        rebuildTagChainForEntity('object', $newmachine, array(getTagByName($tags[$i])));
    }
}