Esempio n. 1
0
function delete_components()
{
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $cid = $router['component'];
    $COMPONENT = new component();
    if ($COMPONENT->deleteComponent($cid)) {
        // Edit Success.
        $code = 200;
        $status = 'ok';
        $message = '';
    } else {
        // Edit Failure.
        $code = 500;
        $status = 'error';
        $message = 'Components could not be deleted.';
    }
    $output = array('status' => "{$status}", 'err-msg' => $message);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
Esempio n. 2
0
                echo "+";
            } else {
                // The component does exist, merge the details in - UPDATE.
                $components[$component_key] = array_merge($components[$component_key], $array);
                echo ".";
            }
        }
        /*
         * Loop over the Component data to see if we need to DELETE any components.
         */
        foreach ($components as $key => $array) {
            // Guilty until proven innocent
            $found = false;
            foreach ($tblCBQOS as $k => $v) {
                if ($array['UID'] == $v['UID']) {
                    // Yay, we found it...
                    $found = true;
                }
            }
            if ($found === false) {
                // The component has not been found. we should delete it.
                echo "-";
                $component->deleteComponent($key);
            }
        }
        // Write the Components back to the DB.
        $component->setComponentPrefs($device['device_id'], $components);
        echo "\n";
    }
    // End if not error
}