コード例 #1
0
function show_all()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $serviceTypes = \Factory::getServiceTypeService()->getServiceTypes();
    $params['ServiceTypes'] = $serviceTypes;
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    show_view('admin/view_service_types.php', $params, 'Service Types');
}
コード例 #2
0
function deny_delete_type()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get a service type service and then the service type to be deleted
    $serv = \Factory::getServiceTypeService();
    $serviceType = $serv->getServiceType($_REQUEST['id']);
    //Get the services for that service and pass them to the denied view
    $params['ServiceType'] = $serviceType;
    $params['Services'] = $serv->getServices($serviceType->getId());
    //display the deletion denied view
    show_view("admin/delete_service_type_denied.php", $params, 'Deletion Failed');
}
コード例 #3
0
ファイル: add_service_type.php プロジェクト: Tom-Byrne/gocdb
/**
 * Retrieves the new service type's data from a portal request and submit it to the
 * services layer's service type functions.
 * @return null
 */
function submit()
{
    require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
    //Get the posted service type data
    $newValues = getSTDataFromWeb();
    //get the user data for the add service type function (so it can check permissions)
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    try {
        //function will through error if user does not have the correct permissions
        $serviceType = \Factory::getServiceTypeService()->addServiceType($newValues, $user);
        $params = array('Name' => $serviceType->getName(), 'Description' => $serviceType->getDescription(), 'ID' => $serviceType->getId());
        show_view("admin/added_service_type.php", $params, "Successfuly added new service type");
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
コード例 #4
0
ファイル: view_service_type.php プロジェクト: Tom-Byrne/gocdb
function view_service_type()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $serv = \Factory::getServiceTypeService();
    $serviceType = $serv->getServiceType($_REQUEST['id']);
    $params['Name'] = $serviceType->getName();
    $params['Description'] = $serviceType->getDescription();
    $params['ID'] = $serviceType->getId();
    $params['Services'] = $serv->getServices($params['ID']);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    show_view("admin/view_service_type.php", $params, $params['Name']);
}
コード例 #5
0
function delete_service_type()
{
    //The following line will be needed if this controller is ever used for non administrators:
    //checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    //Get the service type from the id
    $serv = \Factory::getServiceTypeService();
    $serviceType = $serv->getServiceType($_REQUEST['id']);
    //keep the name to display later
    $params['Name'] = $serviceType->getName();
    //Delete the service type. This fuction will check the user is allowed to
    //perform this action and throw an error if not.
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    try {
        $serv->deleteServiceType($serviceType, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view("admin/deleted_service_type.php", $params, $params['Name'] . 'deleted');
}