Back to index

d-push  2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes
ASDevice Class Reference
Inheritance diagram for ASDevice:
Inheritance graph
[legend]
Collaboration diagram for ASDevice:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ASDevice ($devid, $devicetype, $getuser, $useragent)
 AS Device constructor.
 SetData ($stateObject, $semanticUpdate=true)
 initializes the ASDevice with previousily saved data
 GetData ()
 Returns the current AS Device in it's StateObject If the data was not changed, it returns false (no need to update any data)
 StripData ()
 Removes internal data from the object, so this data can not be exposed.
 IsNewDevice ()
 Indicates if the object was just created.
 GetDeviceUserAgent ()
 
Non-standard Getter and Setter
 GetDeviceUserAgentHistory ()
 Returns the user agent history of this device.
 SetUserAgent ($useragent)
 Sets the useragent of the current request If this value is alreay available, no update is done.
 SetWipeStatus ($status, $requestedBy=false)
 Sets the current remote wipe status.
 SetPolicyKey ($policykey)
 Sets the deployed policy key.
 AddIgnoredMessage ($ignoredMessage)
 Adds a messages which was ignored to the device data.
 RemoveIgnoredMessage ($folderid, $id)
 Removes message in the list of ignored messages.
 HasIgnoredMessage ($folderid, $id)
 Indicates if a message is in the list of ignored messages.
 SetHierarchyCache ($hierarchydata=false)
 
HierarchyCache and ContentData operations
 GetHierarchyCacheData ()
 Returns serialized data of the HierarchyCache.
 GetHierarchyCache ()
 Returns the HierarchyCache Object.
 GetAllFolderIds ()
 Returns all known folderids.
 GetFolderUUID ($folderid=false)
 Returns a linked UUID for a folder id.
 SetFolderUUID ($uuid, $folderid=false)
 Link a UUID to a folder id If a boolean false UUID is sent, the relation is removed.
 GetFolderType ($folderid)
 Returns a foldertype for a folder already known to the mobile.
 SetFolderType ($folderid, $foldertype)
 Sets the foldertype of a folder id.
 GetSupportedFields ($folderid)
 Gets the supported fields transmitted previousely by the device for a certain folder.
 SetSupportedFields ($folderid, $fieldlist)
 Sets the set of supported fields transmitted by the device for a certain folder.
 GetID ()
 Returns the unique id of that data object.
 GetDataArray ()
 Returns the internal array which contains all data of this object.
 SetDataArray ($data, $markAsChanged=false)
 Sets the internal array which contains all data of this object.
 IsDataChanged ()
 Indicates if the data contained in this object was modified.
 __set ($name, $value)
 PHP magic to set an instance variable.
 __get ($name)
 PHP magic to get an instance variable if the variable was not set previousely, the value of the Unsetdata array is returned.
 __isset ($name)
 PHP magic to check if an instance variable is set.
 __unset ($name)
 PHP magic to remove an instance variable.
 __call ($name, $arguments)
 PHP magic to implement any getter, setter, has and delete operations on an instance variable.
 serialize ()
 Method to serialize a StateObject.
 unserialize ($data)
 Method to unserialize a StateObject.

Static Public Member Functions

static ThrowStateInvalidException ()
 Callback function for failed unserialize.

Public Attributes

const UNDEFINED = -1
const FOLDERUUID = 1
const FOLDERTYPE = 2
const FOLDERSUPPORTEDFIELDS = 3

Protected Member Functions

 preSerialize ()
 Called before the StateObject is serialized.
 postUnserialize ()
 Called after the StateObject was unserialized.

Protected Attributes

 $unsetdata
 $newdevice
 $hierarchyCache
 $ignoredMessageIds
 $data = array()
 $changed = false

Static Private Attributes

static $loadedData

Detailed Description

Definition at line 45 of file asdevice.php.


Member Function Documentation

StateObject::__call ( name,
arguments 
) [inherited]

PHP magic to implement any getter, setter, has and delete operations on an instance variable.

Methods like e.g. "SetVariableName($x)" and "GetVariableName()" are supported

public

Returns:
mixed

Reimplemented in SyncParameters, and ContentParameters.

Definition at line 163 of file stateobject.php.

                                              {
        $name = strtolower($name);
        $operator = substr($name, 0,3);
        $var = substr($name,3);

        if ($operator == "set" && count($arguments) == 1){
            $this->$var = $arguments[0];
            return true;
        }

        if ($operator == "set" && count($arguments) == 2 && $arguments[1] === false){
            $this->data[$var] = $arguments[0];
            return true;
        }

        // getter without argument = return variable, null if not set
        if ($operator == "get" && count($arguments) == 0) {
            return $this->$var;
        }

        // getter with one argument = return variable if set, else the argument
        else if ($operator == "get" && count($arguments) == 1) {
            if (isset($this->$var)) {
                return $this->$var;
            }
            else
                return $arguments[0];
        }

        if ($operator == "has" && count($arguments) == 0)
            return isset($this->$var);

        if ($operator == "del" && count($arguments) == 0) {
            unset($this->$var);
            return true;
        }

        throw new FatalNotImplementedException(sprintf("StateObject->__call('%s'): not implemented. op: {$operator} args:". count($arguments), $name));
    }
StateObject::__get ( name) [inherited]

PHP magic to get an instance variable if the variable was not set previousely, the value of the Unsetdata array is returned.

public

Returns:

Definition at line 120 of file stateobject.php.

                                 {
        $lname = strtolower($name);

        if (array_key_exists($lname, $this->data))
            return $this->data[$lname];

        if (isset($this->unsetdata) && is_array($this->unsetdata) && array_key_exists($lname, $this->unsetdata))
            return $this->unsetdata[$lname];

        return null;
    }
StateObject::__isset ( name) [inherited]

PHP magic to check if an instance variable is set.

public

Returns:

Definition at line 138 of file stateobject.php.

                                   {
        return isset($this->data[strtolower($name)]);
    }
StateObject::__set ( name,
value 
) [inherited]

PHP magic to set an instance variable.

public

Returns:

Definition at line 103 of file stateobject.php.

                                         {
        $lname = strtolower($name);
        if (isset($this->data[$lname]) && is_scalar($value) && !is_array($value) && $this->data[$lname] === $value)
            return false;

        $this->data[$lname] = $value;
        $this->changed = true;
    }
StateObject::__unset ( name) [inherited]

PHP magic to remove an instance variable.

public

Returns:

Definition at line 148 of file stateobject.php.

                                   {
        if (isset($this->$name)) {
            unset($this->data[strtolower($name)]);
            $this->changed = true;
        }
    }
ASDevice::AddIgnoredMessage ( ignoredMessage)

Adds a messages which was ignored to the device data.

Parameters:
StateObject$ignoredMessagepublic
Returns:
boolean

Definition at line 322 of file asdevice.php.

                                                       {
        // we should have all previousily ignored messages in an id array
        if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
            foreach($this->ignoredMessages as $oldMessage) {
                if (!isset($this->ignoredMessageIds[$oldMessage->folderid]))
                    $this->ignoredMessageIds[$oldMessage->folderid] = array();
                $this->ignoredMessageIds[$oldMessage->folderid][] = $oldMessage->id;
            }
        }

        // serialize the AS object - if available
        if (isset($ignoredMessage->asobject))
            $ignoredMessage->asobject = serialize($ignoredMessage->asobject);

        // try not to add the same message several times
        if (isset($ignoredMessage->folderid) && isset($ignoredMessage->id)) {
            if (!isset($this->ignoredMessageIds[$ignoredMessage->folderid]))
                $this->ignoredMessageIds[$ignoredMessage->folderid] = array();

            if (in_array($ignoredMessage->id, $this->ignoredMessageIds[$ignoredMessage->folderid]))
                $this->RemoveIgnoredMessage($ignoredMessage->folderid, $ignoredMessage->id);

            $this->ignoredMessageIds[$ignoredMessage->folderid][] = $ignoredMessage->id;
            $msges = $this->ignoredMessages;
            $msges[] = $ignoredMessage;
            $this->ignoredMessages = $msges;

            return true;
        }
        else {
            $msges = $this->ignoredMessages;
            $msges[] = $ignoredMessage;
            $this->ignoredMessages = $msges;
            ZLog::Write(LOGLEVEL_WARN, "ASDevice->AddIgnoredMessage(): added message has no folder/id");
            return true;
        }
    }

Here is the call graph for this function:

ASDevice::ASDevice ( devid,
devicetype,
getuser,
useragent 
)

AS Device constructor.

Parameters:
string$devid
string$devicetype
string$getuser
string$useragentpublic
Returns:

Definition at line 87 of file asdevice.php.

                                                                        {
        $this->deviceid = $devid;
        $this->devicetype = $devicetype;
        list ($this->deviceuser, $this->domain) =  Utils::SplitDomainUser($getuser);
        $this->useragent = $useragent;
        $this->firstsynctime = time();
        $this->newdevice = true;
        $this->ignoredMessageIds = array();
    }

Here is the call graph for this function:

Returns all known folderids.

public

Returns:
array

Definition at line 503 of file asdevice.php.

                                      {
        if (isset($this->contentData) && is_array($this->contentData))
            return array_keys($this->contentData);
        return array();
    }

Returns the current AS Device in it's StateObject If the data was not changed, it returns false (no need to update any data)

public

Returns:
array/boolean

Definition at line 147 of file asdevice.php.

                              {
        if (! $this->changed)
            return false;

        // device was updated
        $this->lastupdatetime = time();
        unset($this->ignoredMessageIds);

        if (!isset(self::$loadedData) || !isset(self::$loadedData->devices) || !is_array(self::$loadedData->devices)) {
            self::$loadedData = new StateObject();
            $devices = array();
        }
        else
            $devices = self::$loadedData->devices;

        $devices[$this->deviceuser] = $this;

        // check if RWStatus has to be updated so it can be updated for other users on same device
        if (isset($this->wipeStatus) && $this->wipeStatus > SYNC_PROVISION_RWSTATUS_OK) {
            foreach ($devices as $user=>$asuserdata) {
                if ($user == $this->deviceuser) continue;
                if (isset($this->wipeStatus))       $asuserdata->wipeStatus     = $this->wipeStatus;
                if (isset($this->wipeRequestBy))    $asuserdata->wipeRequestBy  = $this->wipeRequestBy;
                if (isset($this->wipeRequestOn))    $asuserdata->wipeRequestOn  = $this->wipeRequestOn;
                if (isset($this->wipeActionOn))     $asuserdata->wipeActionOn   = $this->wipeActionOn;
                $devices[$user] = $asuserdata;

                ZLog::Write(LOGLEVEL_DEBUG, sprintf("Updated remote wipe status for user '%s' on the same device", $user));
            }
        }
        self::$loadedData->devices = $devices;
        return self::$loadedData;
    }

Here is the call graph for this function:

StateObject::GetDataArray ( ) [inherited]

Returns the internal array which contains all data of this object.

public

Returns:
array

Definition at line 69 of file stateobject.php.

                                   {
        return $this->data;
    }


Non-standard Getter and Setter

Returns the user agent of this device

public

Returns:
string

Definition at line 230 of file asdevice.php.

                                         {
        if (!isset($this->useragent) || !$this->useragent)
            return "unknown";

        return $this->useragent;
    }

Returns the user agent history of this device.

public

Returns:
string

Definition at line 243 of file asdevice.php.

                                                {
        return $this->useragentHistory;
    }
ASDevice::GetFolderType ( folderid)

Returns a foldertype for a folder already known to the mobile.

Parameters:
string$folderidpublic
Returns:
int/boolean returns false if the type is not set

Definition at line 572 of file asdevice.php.

                                             {
        if (isset($this->contentData) && isset($this->contentData[$folderid]) &&
            isset($this->contentData[$folderid][self::FOLDERTYPE]) )

            return $this->contentData[$folderid][self::FOLDERTYPE];
        return false;
    }
ASDevice::GetFolderUUID ( folderid = false)

Returns a linked UUID for a folder id.

Parameters:
string$folderid(opt) if not set, Hierarchy UUID is returned

public

Returns:
string

Definition at line 517 of file asdevice.php.

                                                     {
        if ($folderid === false)
            return (isset($this->hierarchyUuid) && $this->hierarchyUuid !== self::UNDEFINED) ? $this->hierarchyUuid : false;
        else if (isset($this->contentData) && isset($this->contentData[$folderid]) && isset($this->contentData[$folderid][self::FOLDERUUID]))
            return $this->contentData[$folderid][self::FOLDERUUID];
        return false;
    }

Returns the HierarchyCache Object.

public

Returns:
object HierarchyCache

Definition at line 489 of file asdevice.php.

                                        {
        if (!isset($this->hierarchyCache))
            $this->SetHierarchyCache();

        ZLog::Write(LOGLEVEL_DEBUG, "ASDevice->GetHierarchyCache(): ". $this->hierarchyCache->GetStat());
        return $this->hierarchyCache;
    }

Here is the call graph for this function:

Returns serialized data of the HierarchyCache.

public

Returns:
string

Definition at line 475 of file asdevice.php.

                                            {
        if (isset($this->hierarchyCache))
            return $this->hierarchyCache;

        ZLog::Write(LOGLEVEL_WARN, "ASDevice->GetHierarchyCacheData() has no data! HierarchyCache probably never initialized.");
        return false;
    }

Here is the call graph for this function:

StateObject::GetID ( ) [inherited]

Returns the unique id of that data object.

public

Returns:
array

Definition at line 56 of file stateobject.php.

                            {
        if (!isset($this->SO_internalid))
            $this->SO_internalid = sprintf('%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));

        return $this->SO_internalid;
    }

Here is the caller graph for this function:

Gets the supported fields transmitted previousely by the device for a certain folder.

Parameters:
string$folderidpublic
Returns:
array/boolean false means no supportedFields are available

Definition at line 611 of file asdevice.php.

                                                  {
        if (isset($this->contentData) && isset($this->contentData[$folderid]) &&
            isset($this->contentData[$folderid][self::FOLDERUUID]) && $this->contentData[$folderid][self::FOLDERUUID] !== false &&
            isset($this->contentData[$folderid][self::FOLDERSUPPORTEDFIELDS]) )

            return $this->contentData[$folderid][self::FOLDERSUPPORTEDFIELDS];

        return false;
    }
ASDevice::HasIgnoredMessage ( folderid,
id 
)

Indicates if a message is in the list of ignored messages.

Parameters:
string$folderidparent folder id of the message
string$idmessage id

public

Returns:
boolean

Definition at line 418 of file asdevice.php.

                                                      {
        // we should have all previousily ignored messages in an id array
        if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
            foreach($this->ignoredMessages as $oldMessage) {
                if (!isset($this->ignoredMessageIds[$oldMessage->folderid]))
                    $this->ignoredMessageIds[$oldMessage->folderid] = array();
                $this->ignoredMessageIds[$oldMessage->folderid][] = $oldMessage->id;
            }
        }

        $foundMessage = false;
        // there are ignored messages in that folder
        if (isset($this->ignoredMessageIds[$folderid])) {
            // resync of a folder.. we should remove all previousily ignored messages
            if ($id === false || in_array($id, $this->ignoredMessageIds[$folderid], true)) {
                $foundMessage = true;
            }
        }

        return $foundMessage;
    }
StateObject::IsDataChanged ( ) [inherited]

Indicates if the data contained in this object was modified.

public

Returns:
array

Definition at line 93 of file stateobject.php.

                                    {
        return $this->changed;
    }

Indicates if the object was just created.

public

Returns:
boolean

Definition at line 215 of file asdevice.php.

                                  {
        return (isset($this->newdevice) && $this->newdevice === true);
    }
StateObject::postUnserialize ( ) [protected, inherited]

Called after the StateObject was unserialized.

protected

Returns:
boolean

Reimplemented in SyncParameters.

Definition at line 253 of file stateobject.php.

                                         {
        return true;
    }

Here is the caller graph for this function:

StateObject::preSerialize ( ) [protected, inherited]

Called before the StateObject is serialized.

protected

Returns:
boolean

Reimplemented in SyncParameters, and ContentParameters.

Definition at line 240 of file stateobject.php.

                                      {
        // make sure the object has an id before serialization
        $this->GetID();

        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

ASDevice::RemoveIgnoredMessage ( folderid,
id 
)

Removes message in the list of ignored messages.

Parameters:
string$folderidparent folder id of the message
string$idmessage id

public

Returns:
boolean

Definition at line 369 of file asdevice.php.

                                                         {
        // we should have all previousily ignored messages in an id array
        if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
            foreach($this->ignoredMessages as $oldMessage) {
                if (!isset($this->ignoredMessageIds[$oldMessage->folderid]))
                    $this->ignoredMessageIds[$oldMessage->folderid] = array();
                $this->ignoredMessageIds[$oldMessage->folderid][] = $oldMessage->id;
            }
        }

        $foundMessage = false;
        // there are ignored messages in that folder
        if (isset($this->ignoredMessageIds[$folderid])) {
            // resync of a folder.. we should remove all previousily ignored messages
            if ($id === false || in_array($id, $this->ignoredMessageIds[$folderid], true)) {
                $ignored = $this->ignoredMessages;
                $newMessages = array();
                foreach ($ignored as $im) {
                    if ($im->folderid = $folderid) {
                        if ($id === false || $im->id === $id) {
                            $foundMessage = true;
                            if (count($this->ignoredMessageIds[$folderid]) == 1) {
                                unset($this->ignoredMessageIds[$folderid]);
                            }
                            else {
                                unset($this->ignoredMessageIds[$folderid][array_search($id, $this->ignoredMessageIds[$folderid])]);
                            }
                            continue;
                        }
                        else
                            $newMessages[] = $im;
                    }
                }
                $this->ignoredMessages = $newMessages;
            }
        }

        return $foundMessage;
    }

Here is the caller graph for this function:

StateObject::serialize ( ) [inherited]

Method to serialize a StateObject.

public

Returns:
array

Definition at line 209 of file stateobject.php.

                                {
        // perform tasks just before serialization
        $this->preSerialize();

        return serialize(array($this->SO_internalid,$this->data));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

ASDevice::SetData ( stateObject,
semanticUpdate = true 
)

initializes the ASDevice with previousily saved data

Parameters:
mixed$stateObjectthe StateObject containing the device data
boolean$semanticUpdateindicates if data relevant for all users should be cross checked (e.g. wipe requests)

public

Returns:

Definition at line 106 of file asdevice.php.

                                                                  {
        if (!($stateObject instanceof StateObject) || !isset($stateObject->devices) || !is_array($stateObject->devices)) return;

        // is information about this device & user available?
        if (isset($stateObject->devices[$this->deviceuser]) && $stateObject->devices[$this->deviceuser] instanceof ASDevice) {
            // overwrite local data with data from the saved object
            $this->SetDataArray($stateObject->devices[$this->deviceuser]->GetDataArray());
            $this->newdevice = false;
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice data loaded for user: '%s'", $this->deviceuser));
        }

        // check if RWStatus from another user on same device may require action
        if ($semanticUpdate && count($stateObject->devices) > 1) {
            foreach ($stateObject->devices as $user=>$asuserdata) {
                if ($user == $this->user) continue;

                // another user has a required action on this device
                if (isset($asuserdata->wipeStatus) && $asuserdata->wipeStatus > SYNC_PROVISION_RWSTATUS_OK) {
                    ZLog::Write(LOGLEVEL_INFO, sprintf("User '%s' has requested a remote wipe for this device on '%s'", $asuserdata->wipeRequestBy, strftime("%Y-%m-%d %H:%M", $asuserdata->wipeRequstOn)));

                    // reset status to PENDING if wipe was executed before
                    $this->wipeStatus =  ($asuserdata->wipeStatus & SYNC_PROVISION_RWSTATUS_WIPED)?SYNC_PROVISION_RWSTATUS_PENDING:$asuserdata->wipeStatus;
                    $this->wipeRequestBy =  $asuserdata->wipeRequestBy;
                    $this->wipeRequestOn =  $asuserdata->wipeRequestOn;
                    $this->wipeActionOn = $asuserdata->wipeActionOn;
                    break;
                }
            }
        }

        self::$loadedData = $stateObject;
        $this->changed = false;
    }

Here is the call graph for this function:

StateObject::SetDataArray ( data,
markAsChanged = false 
) [inherited]

Sets the internal array which contains all data of this object.

Parameters:
array$datathe data to be written
boolean$markAsChanged(opt) indicates if the object should be marked as "changed", default false

public

Returns:
array

Definition at line 82 of file stateobject.php.

                                                                {
        $this->data = $data;
        $this->changed = $markAsChanged;
    }

Here is the caller graph for this function:

ASDevice::SetFolderType ( folderid,
foldertype 
)

Sets the foldertype of a folder id.

Parameters:
string$uuid
string$folderid(opt) if not set Hierarchy UUID is linked

public

Returns:
boolean true if the type was set or updated

Definition at line 589 of file asdevice.php.

                                                          {
        $contentData = $this->contentData;

        if (!isset($contentData[$folderid]) || !is_array($contentData[$folderid]))
            $contentData[$folderid] = array();
        if (!isset($contentData[$folderid][self::FOLDERTYPE]) || $contentData[$folderid][self::FOLDERTYPE] != $foldertype ) {
            $contentData[$folderid][self::FOLDERTYPE] = $foldertype;
            $this->contentData = $contentData;
            return true;
        }
        return false;
    }
ASDevice::SetFolderUUID ( uuid,
folderid = false 
)

Link a UUID to a folder id If a boolean false UUID is sent, the relation is removed.

Parameters:
string$uuid
string$folderid(opt) if not set Hierarchy UUID is linked

public

Returns:
boolean

Definition at line 535 of file asdevice.php.

                                                            {
        if ($folderid === false) {
            $this->hierarchyUuid = $uuid;
            // when unsetting the hierarchycache, also remove saved contentdata and ignoredmessages
            if ($folderid === false) {
                $this->contentData = array();
                $this->ignoredMessageIds = array();
                $this->ignoredMessages = array();
            }
        }
        else {

            $contentData = $this->contentData;
            if (!isset($contentData[$folderid]) || !is_array($contentData[$folderid]))
                $contentData[$folderid] = array();

            // check if the foldertype is set. This has to be available at this point, as generated during the first HierarchySync
            if (!isset($contentData[$folderid][self::FOLDERTYPE]))
                return false;

            if ($uuid)
                $contentData[$folderid][self::FOLDERUUID] = $uuid;
            else
                $contentData[$folderid][self::FOLDERUUID] = false;

            $this->contentData = $contentData;
        }
    }
ASDevice::SetHierarchyCache ( hierarchydata = false)


HierarchyCache and ContentData operations

Sets the HierarchyCache The hierarchydata, can be:

Parameters:
string$hierarchydata(opt)

public

Returns:
boolean

Definition at line 456 of file asdevice.php.

                                                              {
        if ($hierarchydata !== false && $hierarchydata instanceof ChangesMemoryWrapper) {
            $this->hierarchyCache = $hierarchydata;
            $this->hierarchyCache->CopyOldState();
        }
        else
            $this->hierarchyCache = new ChangesMemoryWrapper();

        if (is_array($hierarchydata))
            return $this->hierarchyCache->ImportFolders($hierarchydata);
        return true;
    }

Here is the caller graph for this function:

ASDevice::SetPolicyKey ( policykey)

Sets the deployed policy key.

Parameters:
int$policykeypublic
Returns:

Definition at line 308 of file asdevice.php.

                                             {
        $this->policykey = $policykey;
        if ($this->GetWipeStatus() == SYNC_PROVISION_RWSTATUS_NA)
            $this->wipeStatus = SYNC_PROVISION_RWSTATUS_OK;
    }
ASDevice::SetSupportedFields ( folderid,
fieldlist 
)

Sets the set of supported fields transmitted by the device for a certain folder.

Parameters:
string$folderid
array$fieldlistsupported fields

public

Returns:
boolean

Definition at line 630 of file asdevice.php.

                                                              {
        $contentData = $this->contentData;
        if (!isset($contentData[$folderid]) || !is_array($contentData[$folderid]))
            $contentData[$folderid] = array();

        $contentData[$folderid][self::FOLDERSUPPORTEDFIELDS] = $fieldlist;
        $this->contentData = $contentData;
        return true;
    }
ASDevice::SetUserAgent ( useragent)

Sets the useragent of the current request If this value is alreay available, no update is done.

Parameters:
string$useragentpublic
Returns:
boolean

Definition at line 256 of file asdevice.php.

                                             {
        if ($useragent == $this->useragent || $useragent === false || $useragent === Request::UNKNOWN)
            return true;

        // save the old user agent, if available
        if ($this->useragent != "") {
            // [] = changedate, previous user agent
            $a = $this->useragentHistory;
            $a[] = array(time(), $this->useragent);
            $this->useragentHistory = $a;
        }
        $this->useragent = $useragent;
        return true;
    }
ASDevice::SetWipeStatus ( status,
requestedBy = false 
)

Sets the current remote wipe status.

Parameters:
int$status
string$requestedBypublic
Returns:
int

Definition at line 279 of file asdevice.php.

                                                                 {
        // force saving the updated information if there was a transition between the wiping status
        if ($this->wipeStatus > SYNC_PROVISION_RWSTATUS_OK && $status > SYNC_PROVISION_RWSTATUS_OK)
            $this->forceSave = true;

        if ($requestedBy != false) {
            $this->wipeRequestedBy = $requestedBy;
            $this->wipeRequestedOn = time();
        }
        else {
            $this->wipeActionOn = time();
        }

        $this->wipeStatus = $status;

        if ($this->wipeStatus > SYNC_PROVISION_RWSTATUS_PENDING)
            ZLog::Write(LOGLEVEL_INFO, sprintf("ASDevice id '%s' was %s remote wiped on %s. Action requested by user '%s' on %s",
                                        $this->deviceid, ($this->wipeStatus == SYNC_PROVISION_RWSTATUS_REQUESTED ? "requested to be": "sucessfully"),
                                        strftime("%Y-%m-%d %H:%M", $this->wipeActionOn), $this->wipeRequestedBy, strftime("%Y-%m-%d %H:%M", $this->wipeRequestedOn)));
    }

Here is the call graph for this function:

Removes internal data from the object, so this data can not be exposed.

public

Returns:
boolean

Definition at line 187 of file asdevice.php.

                                {
        unset($this->changed);
        unset($this->unsetdata);
        unset($this->hierarchyCache);
        unset($this->forceSave);
        unset($this->newdevice);
        unset($this->ignoredMessageIds);

        if (isset($this->ignoredmessages) && is_array($this->ignoredmessages)) {
            $imessages = $this->ignoredmessages;
            $unserializedMessage = array();
            foreach ($imessages as $im) {
                $im->asobject = unserialize($im->asobject);
                $im->asobject->StripData();
                $unserializedMessage[] = $im;
            }
            $this->ignoredmessages = $unserializedMessage;
        }

        return true;
    }

Here is the call graph for this function:

static StateObject::ThrowStateInvalidException ( ) [static, inherited]

Callback function for failed unserialize.

public

Exceptions:
StateInvalidException

Definition at line 263 of file stateobject.php.

                                                        {
        throw new StateInvalidException("Unserialization failed as class was not found or not compatible");
    }
StateObject::unserialize ( data) [inherited]

Method to unserialize a StateObject.

public

Returns:
array
Exceptions:
StateInvalidException

Definition at line 223 of file stateobject.php.

                                       {
        // throw a StateInvalidException if unserialize fails
        ini_set('unserialize_callback_func', 'StateObject::ThrowStateInvalidException');

        list($this->SO_internalid, $this->data) = unserialize($data);

        // perform tasks just after unserialization
        $this->postUnserialize();
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

StateObject::$changed = false [protected, inherited]

Definition at line 48 of file stateobject.php.

StateObject::$data = array() [protected, inherited]

Definition at line 46 of file stateobject.php.

Definition at line 73 of file asdevice.php.

Definition at line 74 of file asdevice.php.

ASDevice::$loadedData [static, private]

Definition at line 71 of file asdevice.php.

ASDevice::$newdevice [protected]

Definition at line 72 of file asdevice.php.

ASDevice::$unsetdata [protected]
Initial value:
 array(
                                    'useragenthistory' => array(),
                                    'hierarchyuuid' => false,
                                    'contentdata' => array(),
                                    'wipestatus' => SYNC_PROVISION_RWSTATUS_NA,
                                    'wiperequestedby' => false,
                                    'wiperequestedon' => false,
                                    'wipeactionon' => false,
                                    'lastupdatetime' => 0,
                                    'conversationmode' => false,
                                    'policies' => array(),
                                    'policykey' => self::UNDEFINED,
                                    'forcesave' => false,
                                    'asversion' => false,
                                    'ignoredmessages' => array(),
                                    'announcedASversion' => false,
                                )

Reimplemented from StateObject.

Definition at line 53 of file asdevice.php.

Definition at line 50 of file asdevice.php.

Definition at line 49 of file asdevice.php.

Definition at line 48 of file asdevice.php.

const ASDevice::UNDEFINED = -1

Definition at line 46 of file asdevice.php.


The documentation for this class was generated from the following file: