Esempio n. 1
0
/**
 * Retrieves the raw new property data from a portal request and submit it
 * to the services layer's property functions.
 * @param \User $user current user
 * @return null */
function submit(\User $user = null)
{
    $newValues = getEndpointPropDataFromWeb();
    $endpointID = $newValues['ENDPOINTPROPERTIES']['ENDPOINTID'];
    if (!isset($endpointID) || !is_numeric($endpointID)) {
        throw new Exception("An id must be specified");
    }
    if ($newValues['ENDPOINTPROPERTIES']['NAME'] == null || $newValues['ENDPOINTPROPERTIES']['VALUE'] == null) {
        show_view('error.php', "A property name and value must be provided.");
        die;
    }
    $serv = \Factory::getServiceService();
    $sp = $serv->addEndpointProperty($newValues, $user);
    show_view("service/added_endpoint_property.php", $endpointID);
}
Esempio n. 2
0
/**
 * Processes an edit endpoint property request from a web request
 * @param \User $user current user
 * return null
 */
function submit(\User $user = null)
{
    try {
        $newValues = getEndpointPropDataFromWeb();
        $endpointID = $newValues['ENDPOINTPROPERTIES']['ENDPOINTID'];
        $propID = $newValues['ENDPOINTPROPERTIES']['PROP'];
        if ($newValues['ENDPOINTPROPERTIES']['NAME'] == null || $newValues['ENDPOINTPROPERTIES']['VALUE'] == null) {
            show_view('error.php', "A property name and value must be provided.");
            die;
        }
        $property = \Factory::getServiceService()->getEndpointProperty($propID);
        $service = $property->getParentEndpoint()->getService();
        \Factory::getServiceService()->editEndpointProperty($service, $user, $property, $newValues);
        $params['endpointid'] = $endpointID;
        show_view('service/endpoint_property_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}