Back to index

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

List of all members.

Public Member Functions

 ImportChangesCombined (&$backend, $folderid=false, $icc=false)
 Constructor of the ImportChangesCombined class.
 LoadConflicts ($contentparameters, $state)
 Loads objects which are expected to be exported with the state Before importing/saving the actual message from the mobile, a conflict detection should be done.
 ImportMessageChange ($id, $message)
 Imports a single message.
 ImportMessageDeletion ($id)
 Imports a deletion.
 ImportMessageReadFlag ($id, $flags)
 Imports a change in 'read' flag This can never conflict.
 ImportMessageMove ($id, $newfolder)
 Imports a move of a message.
 ImportFolderChange ($folder)
 
Methods to import hierarchy
 ImportFolderDeletion ($id, $parent=false)
 Imports a folder deletion.
 Config ($state, $flags=0)
 Initializes the state and flags.
 GetState ()
 Reads and returns the current state.

Private Attributes

 $backend
 $folderid
 $icc

Detailed Description

Definition at line 44 of file importer.php.


Member Function Documentation

ImportChangesCombined::Config ( state,
flags = 0 
)

Initializes the state and flags.

Parameters:
string$state
int$flagspublic
Returns:
boolean status flag

Implements IChanges.

Definition at line 264 of file importer.php.

                                               {
        ZLog::Write(LOGLEVEL_DEBUG, 'ImportChangesCombined->Config(...)');
        $this->syncstates = $state;
        if(!is_array($this->syncstates))
            $this->syncstates = array();
        ZLog::Write(LOGLEVEL_DEBUG, 'ImportChangesCombined->Config() success');
    }

Here is the call graph for this function:

Reads and returns the current state.

public

Returns:
string

Implements IChanges.

Definition at line 278 of file importer.php.

                               {
        return $this->syncstates;
    }
ImportChangesCombined::ImportChangesCombined ( &$  backend,
folderid = false,
icc = false 
)

Constructor of the ImportChangesCombined class.

Parameters:
object$backend
string$folderid
object$importerpublic

Definition at line 58 of file importer.php.

                                                                                      {
        $this->backend = $backend;
        $this->folderid = $folderid;
        $this->icc = &$icc;
    }


Methods to import hierarchy

Imports a change on a folder

Parameters:
object$folderSyncFolder

public

Returns:
boolean/string status/id of the folder

Implements IImportChanges.

Definition at line 169 of file importer.php.

                                                {
        $id = $folder->serverid;
        $parent = $folder->parentid;
        ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesCombined->ImportFolderChange() ".print_r($folder, 1));
        if($parent == '0') {
            if($id) {
                $backendid = $this->backend->GetBackendId($id);
            }
            else {
                $backendid = $this->backend->config['rootcreatefolderbackend'];
            }
        }
        else {
            $backendid = $this->backend->GetBackendId($parent);
            $parent = $this->backend->GetBackendFolder($parent);
        }

        if(!empty($this->backend->config['backends'][$backendid]['subfolder']) && $id == $backendid.$this->backend->config['delimiter'].'0') {
            ZLog::Write(LOGLEVEL_WARN, "ImportChangesCombined->ImportFolderChange() cannot change static folder");
            return false;
        }

        if($id != false) {
            if($backendid != $this->backend->GetBackendId($id)) {
                ZLog::Write(LOGLEVEL_WARN, "ImportChangesCombined->ImportFolderChange() cannot move folder between two backends");
                return false;
            }
            $id = $this->backend->GetBackendFolder($id);
        }

        $importer = $this->backend->getBackend($backendid)->GetImporter();

        if(isset($this->syncstates[$backendid])) {
            $state = $this->syncstates[$backendid];
        }
        else {
            $state = '';
        }

        $importer->Config($state);
        $res = $importer->ImportFolderChange($folder);
        $this->syncstates[$backendid] = $importer->GetState();
        ZLog::Write(LOGLEVEL_DEBUG, 'ImportChangesCombined->ImportFolderChange() success');
        return $backendid.$this->backend->config['delimiter'].$res;
    }

Here is the call graph for this function:

ImportChangesCombined::ImportFolderDeletion ( id,
parent = false 
)

Imports a folder deletion.

Parameters:
string$id
string$parentid

public

Returns:
boolean/int success/SYNC_FOLDERHIERARCHY_STATUS

Implements IImportChanges.

Definition at line 224 of file importer.php.

                                                               {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesCombined->ImportFolderDeletion('%s', '%s'), $id, $parent"));
        $backendid = $this->backend->GetBackendId($id);
        if(!empty($this->backend->config['backends'][$backendid]['subfolder']) && $id == $backendid.$this->backend->config['delimiter'].'0') {
            ZLog::Write(LOGLEVEL_WARN, "ImportChangesCombined->ImportFolderDeletion() cannot change static folder");
            return false; //we can not change a static subfolder
        }

        $backend = $this->backend->GetBackend($id);
        $id = $this->backend->GetBackendFolder($id);

        if($parent != '0')
            $parent = $this->backend->GetBackendFolder($parent);

        $importer = $backend->GetImporter();

        if(isset($this->syncstates[$backendid])) {
            $state = $this->syncstates[$backendid];
        }
        else {
            $state = '';
        }

        $importer->Config($state);
        $res = $importer->ImportFolderDeletion($id, $parent);
        $this->syncstates[$backendid] = $importer->GetState();
        ZLog::Write(LOGLEVEL_DEBUG, 'ImportChangesCombined->ImportFolderDeletion() success');
        return $res;
    }

Here is the call graph for this function:

ImportChangesCombined::ImportMessageChange ( id,
message 
)

Imports a single message.

Parameters:
string$id
SyncObject$messagepublic
Returns:
boolean/string failure / id of message

Implements IImportChanges.

Definition at line 92 of file importer.php.

                                                       {
        if (!$this->icc) {
            ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageChange() icc not configured");
            return false;
        }
        return $this->icc->ImportMessageChange($id, $message);
    }

Here is the call graph for this function:

Imports a deletion.

This may conflict if the local object has been modified

Parameters:
string$idpublic
Returns:
boolean

Implements IImportChanges.

Definition at line 108 of file importer.php.

                                               {
        if (!$this->icc) {
            ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageDeletion() icc not configured");
            return false;
        }
        return $this->icc->ImportMessageDeletion($id);
    }

Here is the call graph for this function:

ImportChangesCombined::ImportMessageMove ( id,
newfolder 
)

Imports a move of a message.

This occurs when a user moves an item to another folder

Parameters:
string$id
string$newfolderpublic
Returns:
boolean

Implements IImportChanges.

Definition at line 143 of file importer.php.

                                                       {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesCombined->ImportMessageMove('%s', '%s')", $id, $newfolder));
        if (!$this->icc) {
            ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageMove icc not configured");
            return false;
        }
        if($this->backend->GetBackendId($this->folderid) != $this->backend->GetBackendId($newfolder)){
            ZLog::Write(LOGLEVEL_WARN, "ImportChangesCombined->ImportMessageMove() cannot move message between two backends");
            return false;
        }
        return $this->icc->ImportMessageMove($id, $this->backend->GetBackendFolder($newfolder));
    }

Here is the call graph for this function:

Imports a change in 'read' flag This can never conflict.

Parameters:
string$id
int$flagspublic
Returns:
boolean

Implements IImportChanges.

Definition at line 126 of file importer.php.

                                                       {
        if (!$this->icc) {
            ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageReadFlag() icc not configured");
            return false;
        }
        return $this->icc->ImportMessageReadFlag($id, $flags);
    }

Here is the call graph for this function:

ImportChangesCombined::LoadConflicts ( contentparameters,
state 
)

Loads objects which are expected to be exported with the state Before importing/saving the actual message from the mobile, a conflict detection should be done.

Parameters:
ContentParameters$contentparametersclass of objects
string$statepublic
Returns:
boolean
Exceptions:
StatusException

Implements IImportChanges.

Definition at line 75 of file importer.php.

                                                              {
        if (!$this->icc) {
            ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->LoadConflicts() icc not configured");
            return false;
        }
        $this->icc->LoadConflicts($contentparameters, $state);
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 45 of file importer.php.

Definition at line 46 of file importer.php.

Definition at line 47 of file importer.php.


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