ProfileController::noMobile PHP Method

noMobile() public method

Set 'NoMobile' cookie for current user to prevent use of mobile theme.
public noMobile ( string $type = 'desktop' )
$type string The type of mobile device. This can be one of the following: - desktop: Force the desktop theme. - mobile: Force the mobile theme. - tablet: Force the tablet theme (desktop). - app: Force the app theme (app). - 1: Unset the force cookie and use the user agent to determine the theme.
    public function noMobile($type = 'desktop')
    {
        $type = strtolower($type);
        if ($type == '1') {
            Gdn_CookieIdentity::deleteCookie('X-UA-Device-Force');
            redirect("/", 302);
        }
        if (in_array($type, array('mobile', 'desktop', 'tablet', 'app'))) {
            $type = $type;
        } else {
            $type = 'desktop';
        }
        if ($type == '1') {
            // Allow mobile again
            Gdn_CookieIdentity::deleteCookie('VanillaNoMobile');
        } else {
            // Set 48-hour "no mobile" cookie
            $Expiration = time() + 172800;
            $Path = c('Garden.Cookie.Path');
            $Domain = c('Garden.Cookie.Domain');
            safeCookie('X-UA-Device-Force', $type, $Expiration, $Path, $Domain);
        }
        redirect("/", 302);
    }