コード例 #1
0
ファイル: add_site_property.php プロジェクト: Tom-Byrne/gocdb
/**
 * 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 = getSpDataFromWeb();
    $siteID = $newValues['SITEPROPERTIES']['SITE'];
    if ($newValues['SITEPROPERTIES']['NAME'] == null || $newValues['SITEPROPERTIES']['VALUE'] == null) {
        show_view('error.php', "A property name and value must be provided.");
        die;
    }
    $serv = \Factory::getSiteService();
    $sp = $serv->addProperty($newValues, $user);
    show_view("site/added_site_property.php", $siteID);
}
コード例 #2
0
/**
 * Processes an edit site property request from a web request
 * @param \User $user current user
 * return null
 */
function submit(\User $user = null)
{
    try {
        $newValues = getSpDataFromWeb();
        $siteID = $newValues['SITEPROPERTIES']['SITE'];
        $propID = $newValues['SITEPROPERTIES']['PROP'];
        if ($newValues['SITEPROPERTIES']['NAME'] == null || $newValues['SITEPROPERTIES']['VALUE'] == null) {
            show_view('error.php', "A property name and value must be provided.");
            die;
        }
        $property = \Factory::getSiteService()->getProperty($propID);
        $site = \Factory::getSiteService()->getSite($siteID);
        $site = \Factory::getSiteService()->editSiteProperty($site, $user, $property, $newValues);
        $params['siteid'] = $siteID;
        show_view('site/site_property_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}