Esempio n. 1
0
function Users_device_post()
{
    $user = Users::loggedInUser(true);
    $token = isset($_REQUEST['token']) ? $_REQUEST['token'] : null;
    $platform = Q_Request::platform();
    $version = Q_Request::OSVersion();
    $formFactor = Q_Request::isMobile() ? 'mobile' : (Q_Request::isTablet() ? 'tablet' : null);
    $device = new Users_Device();
    $device->userId = $user->id;
    $device->deviceId = $token;
    $device->platform = $platform;
    $device->version = $version;
    $device->formFactor = $formFactor;
    $device->sessionId = Q_Session::id();
    $_SESSION['Users']['deviceId'] = $token;
    Q_Response::setSlot('data', !!$device->save(true));
    Q_Utils::sendToNode(array("Q/method" => "Users/device", "userId" => $user->id, "deviceId" => $token));
}
Esempio n. 2
0
 /**
  * Get or set the layout view that should be used in the response
  * @method layoutView
  * @static
  * @param {string} $new_view optionally set the new view, or unset it by passing false
  * @return {string}
  */
 static function layoutView($new_view = null)
 {
     if (isset($new_view)) {
         return Q_Response::$layout_view = $new_view;
     }
     if (Q_Response::$layout_view) {
         return Q_Response::$layout_view;
     }
     $app = Q_Config::expect('Q', 'app');
     $layout_view = Q_Config::get('Q', 'response', 'layout', 'html', "{$app}/layout/html.php");
     $desktop_layout_view = Q_Config::get('Q', 'response', 'layout', 'desktop', false);
     if ($desktop_layout_view) {
         $layout_view = $desktop_layout_view;
     }
     if (Q_Request::isTablet()) {
         $tablet_layout_view = Q_Config::get('Q', 'response', 'layout', 'tablet', false);
         if ($tablet_layout_view) {
             $layout_view = $tablet_layout_view;
         }
     } else {
         if (Q_Request::isMobile()) {
             $mobile_layout_view = Q_Config::get('Q', 'response', 'layout', 'mobile', false);
             if ($mobile_layout_view) {
                 $layout_view = $mobile_layout_view;
             }
         }
     }
     return $layout_view;
 }
Esempio n. 3
0
 /**
  * Detects whether the request is coming from a mobile browser
  * @method isMobile
  * @static
  * @return {boolean}
  */
 static function isMobile()
 {
     static $result;
     if (isset($result)) {
         return $result;
     }
     /**
      * @event Q/request/isMobile {before}
      * @return {boolean}
      */
     $result = Q::event('Q/request/isMobile', array(), 'before');
     if (isset($result)) {
         return $result;
     }
     return Q_Request::isTouchscreen() and !Q_Request::isTablet();
 }