Example #1
0
/**
 * Performs switch replacement in database
 * 
 * @param int $fromId
 * @param int $toId
 * @param int $employeeid
 * 
 * @return void
 */
function zb_SwitchReplace($fromId, $toId, $employeeId)
{
    $fromId = vf($fromId, 3);
    $toId = vf($toId, 3);
    $employeeId = vf($employeeId, 3);
    $allEmployees = ts_GetAllEmployee();
    $fromData = zb_SwitchGetData($fromId);
    $toData = zb_SwitchGetData($toId);
    if (!empty($fromData)) {
        //copy geo coordinates to new switch
        simple_update_field('switches', 'geo', $fromData['geo'], "WHERE `id`='" . $toId . "'");
        //setting new description and remove NP flag
        $newDescriptionTo = str_replace('NP', 'm:' . @$allEmployees[$employeeId], $toData['desc']);
        simple_update_field('switches', 'desc', $newDescriptionTo, "WHERE `id`='" . $toId . "'");
        //copy location
        simple_update_field('switches', 'location', $fromData['location'], "WHERE `id`='" . $toId . "'");
        //copy switch parent ID
        if (!empty($fromData['parentid'])) {
            simple_update_field('switches', 'parentid', $fromData['parentid'], "WHERE `id`='" . $toId . "'");
        } else {
            $parentId_q = "UPDATE `switches` SET `parentid`=NULL WHERE `id`='" . $toId . "';";
            nr_query($parentId_q);
        }
        //moving childs if it present
        simple_update_field('switches', 'parentid', $toId, "WHERE `parentid`='" . $fromId . "'");
        // doing old switch cleanup and disabling it
        simple_update_field('switches', 'geo', '', "WHERE `id`='" . $fromId . "'");
        $newFromLocation = __('removed from') . ': ' . $fromData['location'];
        simple_update_field('switches', 'location', $newFromLocation, "WHERE `id`='" . $fromId . "'");
        $newFromDesc = 'NP u:' . @$allEmployees[$employeeId];
        simple_update_field('switches', 'desc', $newFromDesc, "WHERE `id`='" . $fromId . "'");
        $parentIdFrom_q = "UPDATE `switches` SET `parentid`=NULL WHERE `id`='" . $fromId . "';";
        nr_query($parentIdFrom_q);
        log_register("SWITCH REPLACE FROM [" . $fromId . "] TO [" . $toId . "] EMPLOYEE [" . $employeeId . "]");
    } else {
        show_error(__('Strange exeption') . ': FROM_SWITCH_EMPTY_DATA');
    }
}
Example #2
0
                 //search processing
                 $timeMachine = ub_SwitchesTimeMachineSearch($_POST['switchdeadlogsearch']);
             }
             $timeMachineCleanupControl = wf_JSAlert('?module=switches&timemachine=true&flushalldead=true', wf_img('skins/icon_cleanup.png', __('Cleanup')), __('Are you serious'));
             //here some searchform
             $timeMachineSearchForm = web_SwitchTimeMachineSearchForm() . wf_tag('br');
             show_window(__('Dead switches time machine') . ' ' . $timeMachineCleanupControl, $timeMachineSearchForm . $timeMachine);
         } else {
             //showing dead switches snapshot
             ub_SwitchesTimeMachineShowSnapshot($_GET['snapshot']);
         }
     }
 } else {
     //editing switch form
     $switchid = vf($_GET['edit'], 3);
     $switchdata = zb_SwitchGetData($switchid);
     //if someone edit switch
     if (wf_CheckPost(array('editmodel'))) {
         if (cfr('SWITCHESEDIT')) {
             simple_update_field('switches', 'modelid', $_POST['editmodel'], "WHERE `id`='" . $switchid . "'");
             simple_update_field('switches', 'ip', $_POST['editip'], "WHERE `id`='" . $switchid . "'");
             simple_update_field('switches', 'location', $_POST['editlocation'], "WHERE `id`='" . $switchid . "'");
             simple_update_field('switches', 'desc', $_POST['editdesc'], "WHERE `id`='" . $switchid . "'");
             simple_update_field('switches', 'snmp', $_POST['editsnmp'], "WHERE `id`='" . $switchid . "'");
             simple_update_field('switches', 'geo', $_POST['editgeo'], "WHERE `id`='" . $switchid . "'");
             if ($_POST['editparentid'] != $switchid) {
                 simple_update_field('switches', 'parentid', $_POST['editparentid'], "WHERE `id`='" . $switchid . "'");
             }
             log_register('SWITCH CHANGE [' . $switchid . ']' . ' IP ' . $_POST['editip'] . " LOC `" . $_POST['editlocation'] . "`");
             rcms_redirect("?module=switches&edit=" . $switchid);
         } else {
Example #3
0
<?php

if (cfr('SWITCHESEDIT')) {
    if (wf_CheckGet(array('switchid'))) {
        //run replace
        if (wf_CheckPost(array('switchreplace', 'toswtichreplace', 'replaceemployeeid'))) {
            zb_SwitchReplace($_POST['switchreplace'], $_POST['toswtichreplace'], $_POST['replaceemployeeid']);
            rcms_redirect('?module=switches&edit=' . $_POST['toswtichreplace']);
        }
        //display form
        $switchId = vf($_GET['switchid'], 3);
        $switchData = zb_SwitchGetData($switchId);
        show_window(__('Switch replacement') . ': ' . $switchData['location'] . ' - ' . $switchData['ip'], zb_SwitchReplaceForm($switchId));
    } else {
        show_error(__('Strange exeption'));
    }
} else {
    show_error(__('Access denied'));
}