Back to index

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

List of all members.

Public Member Functions

 Logon ($username, $domain, $password)
 
default backend methods
 Logoff ()
 Logs off.
 SendMail ($sm)
 Sends an e-mail Not implemented here.
 GetWasteBasket ()
 Returns the waste basket.
 GetAttachmentData ($attname)
 Returns the content of the named attachment as stream not implemented.
 GetFolderList ()
 
implemented DiffBackend methods
 GetFolder ($id)
 Returns an actual SyncFolder object.
 StatFolder ($id)
 Returns folder stats.
 ChangeFolder ($folderid, $oldid, $displayname, $type)
 Creates or modifies a folder not implemented.
 DeleteFolder ($id, $parentid)
 Deletes a folder.
 GetMessageList ($folderid, $cutoffdate)
 Returns a list (array) of messages.
 GetMessage ($folderid, $id, $contentparameters)
 Returns the actual SyncXXX object type.
 StatMessage ($folderid, $id)
 Returns message stats, analogous to the folder stats from StatFolder().
 ChangeMessage ($folderid, $id, $message)
 Called when a message has been changed on the mobile.
 SetReadFlag ($folderid, $id, $flags)
 Changes the 'read' flag of a message on disk.
 DeleteMessage ($folderid, $id)
 Called when the user has requested to delete (really delete) a message.
 MoveMessage ($folderid, $id, $newfolderid)
 Called when the user moves an item on the PDA from one folder to another not implemented.
 escape ($data)
 Escapes a string.
 unescape ($data)
 Un-escapes a string.
 Setup ($store, $checkACLonly=false, $folderid=false)
 Setup the backend to work on a specific store or checks ACLs there.
 GetHierarchy ()
 Returns an array of SyncFolder types with the entire folder hierarchy on the server (the array itself is flat, but refers to parents via the 'parent' property.
 GetImporter ($folderid=false)
 Returns the importer to process changes from the mobile If no $folderid is given, hierarchy importer is expected.
 GetExporter ($folderid=false)
 Returns the exporter to send changes to the mobile If no $folderid is given, hierarchy exporter is expected.
 Fetch ($folderid, $id, $contentparameters)
 Returns all available data of a single message.
 MeetingResponse ($requestid, $folderid, $response)
 Processes a response to a meeting request.
 Backend ()
 Constructor.
 GetStateMachine ()
 Returns a IStateMachine implementation used to save states The default StateMachine should be used here, so, false is fine.
 GetSearchProvider ()
 Returns a ISearchProvider implementation used for searches the SearchProvider is just a stub.
 GetSupportedASVersion ()
 Indicates which AS version is supported by the backend.
 EmptyFolder ($folderid, $includeSubfolders=true)
 Deletes all contents of the specified folder.
 HasChangesSink ()
 Indicates if the backend has a ChangesSink.
 ChangesSinkInitialize ($folderid)
 The folder should be considered by the sink.
 ChangesSink ($timeout=30)
 The actual ChangesSink.
 Settings ($settings)
 Applies settings to and gets informations from the device.

Protected Member Functions

 InitializePermanentStorage ()
 
Protected methods for BackendStorage
 InitializeStateStorage ()
 Loads the state related storage data of the user and device All data not necessary for the next state should be removed.
 SaveStorages ()
 Saves the permanent and state related storage data of the user and device if they were loaded previousily If the backend storage is used this should be called.

Protected Attributes

 $store
 $permanentStorage
 $stateStorage

Private Member Functions

 getPath ()
 
private vcard-specific internals

Detailed Description

Definition at line 45 of file vcarddir.php.


Member Function Documentation

Backend::Backend ( ) [inherited]

Constructor.

public

Definition at line 67 of file backend.php.

                              {
    }

Here is the caller graph for this function:

BackendVCardDir::ChangeFolder ( folderid,
oldid,
displayname,
type 
)

Creates or modifies a folder not implemented.

Parameters:
string$folderidid of the parent folder
string$oldidif empty -> new folder created, else folder is to be renamed
string$displaynamenew folder name (to be created, or to be renamed to)
int$typefolder type

public

Returns:
boolean status
Exceptions:
StatusExceptioncould throw specific SYNC_FSSTATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 190 of file vcarddir.php.

                                                                        {
        return false;
    }
BackendVCardDir::ChangeMessage ( folderid,
id,
message 
)

Called when a message has been changed on the mobile.

This functionality is not available for emails.

Parameters:
string$folderidid of the folder
string$idid of the message
SyncXXX$messagethe SyncObject containing a message

public

Returns:
array same return value as StatMessage()
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 502 of file vcarddir.php.

                                                            {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::ChangeMessage('.$folderid.', '.$id.', ..)');
        $mapping = array(
            'fileas' => 'FN',
            'lastname;firstname;middlename;title;suffix' => 'N',
            'email1address' => 'EMAIL;INTERNET',
            'email2address' => 'EMAIL;INTERNET',
            'email3address' => 'EMAIL;INTERNET',
            'businessphonenumber' => 'TEL;WORK',
            'business2phonenumber' => 'TEL;WORK',
            'businessfaxnumber' => 'TEL;WORK;FAX',
            'homephonenumber' => 'TEL;HOME',
            'home2phonenumber' => 'TEL;HOME',
            'homefaxnumber' => 'TEL;HOME;FAX',
            'mobilephonenumber' => 'TEL;CELL',
            'carphonenumber' => 'TEL;CAR',
            'pagernumber' => 'TEL;PAGER',
            ';;businessstreet;businesscity;businessstate;businesspostalcode;businesscountry' => 'ADR;WORK',
            ';;homestreet;homecity;homestate;homepostalcode;homecountry' => 'ADR;HOME',
            ';;otherstreet;othercity;otherstate;otherpostalcode;othercountry' => 'ADR',
            'companyname' => 'ORG',
            'body' => 'NOTE',
            'jobtitle' => 'ROLE',
            'webpage' => 'URL',
        );
        $data = "BEGIN:VCARD\nVERSION:2.1\nPRODID:Z-Push\n";
        foreach($mapping as $k => $v){
            $val = '';
            $ks = explode(';', $k);
            foreach($ks as $i){
                if(!empty($message->$i))
                    $val .= $this->escape($message->$i);
                $val.=';';
            }
            if(empty($val))
                continue;
            $val = substr($val,0,-1);
            if(strlen($val)>50){
                $data .= $v.":\n\t".substr(chunk_split($val, 50, "\n\t"), 0, -1);
            }else{
                $data .= $v.':'.$val."\n";
            }
        }
        if(!empty($message->categories))
            $data .= 'CATEGORIES:'.implode(',', $this->escape($message->categories))."\n";
        if(!empty($message->picture))
            $data .= 'PHOTO;ENCODING=BASE64;TYPE=JPEG:'."\n\t".substr(chunk_split($message->picture, 50, "\n\t"), 0, -1);
        if(isset($message->birthday))
            $data .= 'BDAY:'.date('Y-m-d', $message->birthday)."\n";
        $data .= "END:VCARD";

// not supported: anniversary, assistantname, assistnamephonenumber, children, department, officelocation, radiophonenumber, spouse, rtf

        if(!$id){
            if(!empty($message->fileas)){
                $name = u2wi($message->fileas);
            }elseif(!empty($message->lastname)){
                $name = $name = u2wi($message->lastname);
            }elseif(!empty($message->firstname)){
                $name = $name = u2wi($message->firstname);
            }elseif(!empty($message->companyname)){
                $name = $name = u2wi($message->companyname);
            }else{
                $name = 'unknown';
            }
            $name = preg_replace('/[^a-z0-9 _-]/i', '', $name);
            $id = $name.'.vcf';
            $i = 0;
            while(file_exists($this->getPath().'/'.$id)){
                $i++;
                $id = $name.$i.'.vcf';
            }
        }
        file_put_contents($this->getPath().'/'.$id, $data);
        return $this->StatMessage($folderid, $id);
    }

Here is the call graph for this function:

Backend::ChangesSink ( timeout = 30) [inherited]

The actual ChangesSink.

For max. the $timeout value this method should block and if no changes are available return an empty array. If changes are available a list of folderids is expected.

Parameters:
int$timeoutmax. amount of seconds to block

public

Returns:
array

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 173 of file backend.php.

                                               {
        return array();
    }
Backend::ChangesSinkInitialize ( folderid) [inherited]

The folder should be considered by the sink.

Folders which were not initialized should not result in a notification of IBacken->ChangesSink().

Parameters:
string$folderidpublic
Returns:
boolean false if there is any problem with that folder

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 158 of file backend.php.

                                                      {
         return false;
     }
BackendVCardDir::DeleteFolder ( id,
parentid 
)

Deletes a folder.

Parameters:
string$id
string$parentis normally false

public

Returns:
boolean status - false if e.g. does not exist
Exceptions:
StatusExceptioncould throw specific SYNC_FSSTATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 205 of file vcarddir.php.

                                                {
        return false;
    }
BackendVCardDir::DeleteMessage ( folderid,
id 
)

Called when the user has requested to delete (really delete) a message.

Parameters:
string$folderidid of the folder
string$idid of the message

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 604 of file vcarddir.php.

                                                  {
        return unlink($this->getPath() . '/' . $id);
    }

Here is the call graph for this function:

Backend::EmptyFolder ( folderid,
includeSubfolders = true 
) [inherited]

Deletes all contents of the specified folder.

This is generally used to empty the trash (wastebasked), but could also be used on any other folder.

Parameters:
string$folderid
boolean$includeSubfolders(opt) also delete sub folders, default true

public

Returns:
boolean
Exceptions:
StatusException

Implements IBackend.

Definition at line 133 of file backend.php.

                                                                      {
        return false;
    }

Escapes a string.

Parameters:
string$datastring to be escaped

private

Returns:
string

Definition at line 647 of file vcarddir.php.

                          {
        if (is_array($data)) {
            foreach ($data as $key => $val) {
                $data[$key] = $this->escape($val);
            }
            return $data;
        }
        $data = str_replace("\r\n", "\n", $data);
        $data = str_replace("\r", "\n", $data);
        $data = str_replace(array('\\', ';', ',', "\n"), array('\\\\', '\\;', '\\,', '\\n'), $data);
        return u2wi($data);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendDiff::Fetch ( folderid,
id,
contentparameters 
) [inherited]

Returns all available data of a single message.

Parameters:
string$folderid
string$id
ContentParameters$contentparametersflag

public

Returns:
object(SyncObject)
Exceptions:
StatusException

Implements IBackend.

Definition at line 150 of file diffbackend.php.

                                                              {
        // override truncation
        $contentparameters->SetTruncation(SYNC_TRUNCATION_ALL);
        $msg = $this->GetMessage($folderid, $id, $contentparameters);
        if ($msg === false)
            throw new StatusException("BackendDiff->Fetch('%s','%s'): Error, unable retrieve message from backend", SYNC_STATUS_OBJECTNOTFOUND);
        return $msg;
    }

Here is the call graph for this function:

Returns the content of the named attachment as stream not implemented.

Parameters:
string$attnamepublic
Returns:
SyncItemOperationsAttachment
Exceptions:
StatusException

Implements IBackend.

Definition at line 111 of file vcarddir.php.

                                                {
        return false;
    }
BackendDiff::GetExporter ( folderid = false) [inherited]

Returns the exporter to send changes to the mobile If no $folderid is given, hierarchy exporter is expected.

Parameters:
string$folderid(opt)

public

Returns:
object(ExportChanges)
Exceptions:
StatusException

Implements IBackend.

Definition at line 135 of file diffbackend.php.

                                                   {
        return new ExportChangesDiff($this, $folderid);
    }

Returns an actual SyncFolder object.

Parameters:
string$idid of the folder

public

Returns:
object SyncFolder with information

Reimplemented from BackendDiff.

Definition at line 143 of file vcarddir.php.

                                   {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::GetFolder('.$id.')');
        if($id == "root") {
            $folder = new SyncFolder();
            $folder->serverid = $id;
            $folder->parentid = "0";
            $folder->displayname = "Contacts";
            $folder->type = SYNC_FOLDER_TYPE_CONTACT;

            return $folder;
        } else return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


implemented DiffBackend methods

Returns a list (array) of folders. In simple implementations like this one, probably just one folder is returned.

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 126 of file vcarddir.php.

                                    {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::GetFolderList()');
        $contacts = array();
        $folder = $this->StatFolder("root");
        $contacts[] = $folder;

        return $contacts;
    }

Here is the call graph for this function:

BackendDiff::GetHierarchy ( ) [inherited]

Returns an array of SyncFolder types with the entire folder hierarchy on the server (the array itself is flat, but refers to parents via the 'parent' property.

provides AS 1.0 compatibility

public

Returns:
array SYNC_FOLDER

Implements IBackend.

Definition at line 100 of file diffbackend.php.

                            {
        $folders = array();

        $fl = $this->GetFolderList();
        if (is_array($fl))
            foreach($fl as $f)
                $folders[] = $this->GetFolder($f['id']);

        return $folders;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendDiff::GetImporter ( folderid = false) [inherited]

Returns the importer to process changes from the mobile If no $folderid is given, hierarchy importer is expected.

Parameters:
string$folderid(opt)

public

Returns:
object(ImportChanges)
Exceptions:
StatusException

Implements IBackend.

Definition at line 121 of file diffbackend.php.

                                                   {
        return new ImportChangesDiff($this, $folderid);
    }
BackendVCardDir::GetMessage ( folderid,
id,
contentparameters 
)

Returns the actual SyncXXX object type.

Parameters:
string$folderidid of the parent folder
string$idid of the message
ContentParameters$contentparametersparameters of the requested message (truncation, mimesupport etc)

public

Returns:
object/false false if the message could not be retrieved

Reimplemented from BackendDiff.

Definition at line 252 of file vcarddir.php.

                                                                   {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::GetMessage('.$folderid.', '.$id.', ..)');
        if($folderid != "root")
            return;

        $types = array ('dom' => 'type', 'intl' => 'type', 'postal' => 'type', 'parcel' => 'type', 'home' => 'type', 'work' => 'type',
            'pref' => 'type', 'voice' => 'type', 'fax' => 'type', 'msg' => 'type', 'cell' => 'type', 'pager' => 'type',
            'bbs' => 'type', 'modem' => 'type', 'car' => 'type', 'isdn' => 'type', 'video' => 'type',
            'aol' => 'type', 'applelink' => 'type', 'attmail' => 'type', 'cis' => 'type', 'eworld' => 'type',
            'internet' => 'type', 'ibmmail' => 'type', 'mcimail' => 'type',
            'powershare' => 'type', 'prodigy' => 'type', 'tlx' => 'type', 'x400' => 'type',
            'gif' => 'type', 'cgm' => 'type', 'wmf' => 'type', 'bmp' => 'type', 'met' => 'type', 'pmb' => 'type', 'dib' => 'type',
            'pict' => 'type', 'tiff' => 'type', 'pdf' => 'type', 'ps' => 'type', 'jpeg' => 'type', 'qtime' => 'type',
            'mpeg' => 'type', 'mpeg2' => 'type', 'avi' => 'type',
            'wave' => 'type', 'aiff' => 'type', 'pcm' => 'type',
            'x509' => 'type', 'pgp' => 'type', 'text' => 'value', 'inline' => 'value', 'url' => 'value', 'cid' => 'value', 'content-id' => 'value',
            '7bit' => 'encoding', '8bit' => 'encoding', 'quoted-printable' => 'encoding', 'base64' => 'encoding',
        );


        // Parse the vcard
        $message = new SyncContact();

        $data = file_get_contents($this->getPath() . "/" . $id);
        $data = str_replace("\x00", '', $data);
        $data = str_replace("\r\n", "\n", $data);
        $data = str_replace("\r", "\n", $data);
        $data = preg_replace('/(\n)([ \t])/i', '', $data);

        $lines = explode("\n", $data);

        $vcard = array();
        foreach($lines as $line) {
            if (trim($line) == '')
                continue;
            $pos = strpos($line, ':');
            if ($pos === false)
                continue;

            $field = trim(substr($line, 0, $pos));
            $value = trim(substr($line, $pos+1));

            $fieldparts = preg_split('/(?<!\\\\)(\;)/i', $field, -1, PREG_SPLIT_NO_EMPTY);

            $type = strtolower(array_shift($fieldparts));

            $fieldvalue = array();

            foreach ($fieldparts as $fieldpart) {
                if(preg_match('/([^=]+)=(.+)/', $fieldpart, $matches)){
                    if(!in_array(strtolower($matches[1]),array('value','type','encoding','language')))
                        continue;
                    if(isset($fieldvalue[strtolower($matches[1])]) && is_array($fieldvalue[strtolower($matches[1])])){
                        $fieldvalue[strtolower($matches[1])] = array_merge($fieldvalue[strtolower($matches[1])], preg_split('/(?<!\\\\)(\,)/i', $matches[2], -1, PREG_SPLIT_NO_EMPTY));
                    }else{
                        $fieldvalue[strtolower($matches[1])] = preg_split('/(?<!\\\\)(\,)/i', $matches[2], -1, PREG_SPLIT_NO_EMPTY);
                    }
                }else{
                    if(!isset($types[strtolower($fieldpart)]))
                        continue;
                    $fieldvalue[$types[strtolower($fieldpart)]][] = $fieldpart;
                }
            }
            //
            switch ($type) {
                case 'categories':
                    //case 'nickname':
                    $val = preg_split('/(?<!\\\\)(\,)/i', $value);
                    $val = array_map("w2ui", $val);
                    break;
                default:
                    $val = preg_split('/(?<!\\\\)(\;)/i', $value);
                    break;
            }
            if(isset($fieldvalue['encoding'][0])){
                switch(strtolower($fieldvalue['encoding'][0])){
                    case 'q':
                    case 'quoted-printable':
                        foreach($val as $i => $v){
                            $val[$i] = quoted_printable_decode($v);
                        }
                        break;
                    case 'b':
                    case 'base64':
                        foreach($val as $i => $v){
                            $val[$i] = base64_decode($v);
                        }
                        break;
                }
            }else{
                foreach($val as $i => $v){
                    $val[$i] = $this->unescape($v);
                }
            }
            $fieldvalue['val'] = $val;
            $vcard[$type][] = $fieldvalue;
        }

        if(isset($vcard['email'][0]['val'][0]))
            $message->email1address = $vcard['email'][0]['val'][0];
        if(isset($vcard['email'][1]['val'][0]))
            $message->email2address = $vcard['email'][1]['val'][0];
        if(isset($vcard['email'][2]['val'][0]))
            $message->email3address = $vcard['email'][2]['val'][0];

        if(isset($vcard['tel'])){
            foreach($vcard['tel'] as $tel) {
                if(!isset($tel['type'])){
                    $tel['type'] = array();
                }
                if(in_array('car', $tel['type'])){
                    $message->carphonenumber = $tel['val'][0];
                }elseif(in_array('pager', $tel['type'])){
                    $message->pagernumber = $tel['val'][0];
                }elseif(in_array('cell', $tel['type'])){
                    $message->mobilephonenumber = $tel['val'][0];
                }elseif(in_array('home', $tel['type'])){
                    if(in_array('fax', $tel['type'])){
                        $message->homefaxnumber = $tel['val'][0];
                    }elseif(empty($message->homephonenumber)){
                        $message->homephonenumber = $tel['val'][0];
                    }else{
                        $message->home2phonenumber = $tel['val'][0];
                    }
                }elseif(in_array('work', $tel['type'])){
                    if(in_array('fax', $tel['type'])){
                        $message->businessfaxnumber = $tel['val'][0];
                    }elseif(empty($message->businessphonenumber)){
                        $message->businessphonenumber = $tel['val'][0];
                    }else{
                        $message->business2phonenumber = $tel['val'][0];
                    }
                }elseif(empty($message->homephonenumber)){
                    $message->homephonenumber = $tel['val'][0];
                }elseif(empty($message->home2phonenumber)){
                    $message->home2phonenumber = $tel['val'][0];
                }else{
                    $message->radiophonenumber = $tel['val'][0];
                }
            }
        }
        //;;street;city;state;postalcode;country
        if(isset($vcard['adr'])){
            foreach($vcard['adr'] as $adr) {
                if(empty($adr['type'])){
                    $a = 'other';
                }elseif(in_array('home', $adr['type'])){
                    $a = 'home';
                }elseif(in_array('work', $adr['type'])){
                    $a = 'business';
                }else{
                    $a = 'other';
                }
                if(!empty($adr['val'][2])){
                    $b=$a.'street';
                    $message->$b = w2ui($adr['val'][2]);
                }
                if(!empty($adr['val'][3])){
                    $b=$a.'city';
                    $message->$b = w2ui($adr['val'][3]);
                }
                if(!empty($adr['val'][4])){
                    $b=$a.'state';
                    $message->$b = w2ui($adr['val'][4]);
                }
                if(!empty($adr['val'][5])){
                    $b=$a.'postalcode';
                    $message->$b = w2ui($adr['val'][5]);
                }
                if(!empty($adr['val'][6])){
                    $b=$a.'country';
                    $message->$b = w2ui($adr['val'][6]);
                }
            }
        }

        if(!empty($vcard['fn'][0]['val'][0]))
            $message->fileas = w2ui($vcard['fn'][0]['val'][0]);
        if(!empty($vcard['n'][0]['val'][0]))
            $message->lastname = w2ui($vcard['n'][0]['val'][0]);
        if(!empty($vcard['n'][0]['val'][1]))
            $message->firstname = w2ui($vcard['n'][0]['val'][1]);
        if(!empty($vcard['n'][0]['val'][2]))
            $message->middlename = w2ui($vcard['n'][0]['val'][2]);
        if(!empty($vcard['n'][0]['val'][3]))
            $message->title = w2ui($vcard['n'][0]['val'][3]);
        if(!empty($vcard['n'][0]['val'][4]))
            $message->suffix = w2ui($vcard['n'][0]['val'][4]);
        if(!empty($vcard['bday'][0]['val'][0])){
            $tz = date_default_timezone_get();
            date_default_timezone_set('UTC');
            $message->birthday = strtotime($vcard['bday'][0]['val'][0]);
            date_default_timezone_set($tz);
        }
        if(!empty($vcard['org'][0]['val'][0]))
            $message->companyname = w2ui($vcard['org'][0]['val'][0]);
        if(!empty($vcard['note'][0]['val'][0])){
            $message->body = w2ui($vcard['note'][0]['val'][0]);
            $message->bodysize = strlen($vcard['note'][0]['val'][0]);
            $message->bodytruncated = 0;
        }
        if(!empty($vcard['role'][0]['val'][0]))
            $message->jobtitle = w2ui($vcard['role'][0]['val'][0]);//$vcard['title'][0]['val'][0]
        if(!empty($vcard['url'][0]['val'][0]))
            $message->webpage = w2ui($vcard['url'][0]['val'][0]);
        if(!empty($vcard['categories'][0]['val']))
            $message->categories = $vcard['categories'][0]['val'];

        if(!empty($vcard['photo'][0]['val'][0]))
            $message->picture = base64_encode($vcard['photo'][0]['val'][0]);

        return $message;
    }

Here is the call graph for this function:

BackendVCardDir::GetMessageList ( folderid,
cutoffdate 
)

Returns a list (array) of messages.

Parameters:
string$folderidid of the parent folder
long$cutoffdatetimestamp in the past from which on messages should be returned

public

Returns:
array/false array with messages or false if folder is not available

Reimplemented from BackendDiff.

Definition at line 218 of file vcarddir.php.

                                                           {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::GetMessageList('.$folderid.')');
        $messages = array();

        $dir = opendir($this->getPath());
        if(!$dir)
            return false;

        while($entry = readdir($dir)) {
            if(is_dir($this->getPath() .'/'.$entry))
                continue;

            $message = array();
            $message["id"] = $entry;
            $stat = stat($this->getPath() .'/'.$entry);
            $message["mod"] = $stat["mtime"];
            $message["flags"] = 1; // always 'read'

            $messages[] = $message;
        }

        return $messages;
    }

Here is the call graph for this function:

BackendVCardDir::getPath ( ) [private]


private vcard-specific internals

The path we're working on

private

Returns:
string

Definition at line 635 of file vcarddir.php.

                               {
        return str_replace('%u', $this->store, VCARDDIR_DIR);
    }

Here is the caller graph for this function:

Backend::GetSearchProvider ( ) [inherited]

Returns a ISearchProvider implementation used for searches the SearchProvider is just a stub.

public

Returns:
object Implementation of ISearchProvider

Implements IBackend.

Definition at line 88 of file backend.php.

                                        {
        return new SearchProvider();
    }
Backend::GetStateMachine ( ) [inherited]

Returns a IStateMachine implementation used to save states The default StateMachine should be used here, so, false is fine.

public

Returns:
boolean/object

Implements IBackend.

Definition at line 77 of file backend.php.

                                      {
        return false;
    }

Indicates which AS version is supported by the backend.

By default AS version 2.5 (ASV_25) is returned (Z-Push 1 standard). Subclasses can overwrite this method to set another AS version

public

Returns:
string AS version constant

Implements IBackend.

Definition at line 100 of file backend.php.

                                            {
        return ZPush::ASV_25;
    }

Returns the waste basket.

public

Returns:
string

Implements IBackend.

Definition at line 97 of file vcarddir.php.

                                     {
        return false;
    }
Backend::HasChangesSink ( ) [inherited]

Indicates if the backend has a ChangesSink.

A sink is an active notification mechanism which does not need polling.

public

Returns:
boolean

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 144 of file backend.php.

                                     {
        return false;
    }
Backend::InitializePermanentStorage ( ) [protected, inherited]


Protected methods for BackendStorage

Backends can use a permanent and a state related storage to save additional data used during the synchronization.

While permament storage is bound to the device and user, state related data works linked to the regular states (and its counters).

Both consist of a StateObject, while the backend can decide what to save in it.

Before using $this->permanentStorage and $this->stateStorage the initilize methods have to be called from the backend.

Backend->LogOff() must call $this->SaveStorages() so the data is written to disk!

These methods are an abstraction layer for StateManager->Get/SetBackendStorage() which can also be used independently. Loads the permanent storage data of the user and device

protected

Returns:

Definition at line 218 of file backend.php.

                                                    {
        if (!isset($this->permanentStorage)) {
            try {
                $this->permanentStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_PERMANENT);
            }
            catch (StateNotYetAvailableException $snyae) {
                $this->permanentStorage = new StateObject();
            }
            catch(StateNotFoundException $snfe) {
                $this->permanentStorage = new StateObject();
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Backend::InitializeStateStorage ( ) [protected, inherited]

Loads the state related storage data of the user and device All data not necessary for the next state should be removed.

protected

Returns:

Definition at line 239 of file backend.php.

                                                {
        if (!isset($this->stateStorage)) {
            try {
                $this->stateStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_STATE);
            }
            catch (StateNotYetAvailableException $snyae) {
                $this->stateStorage = new StateObject();
            }
            catch(StateNotFoundException $snfe) {
                $this->stateStorage = new StateObject();
            }
        }
    }

Here is the call graph for this function:

Logs off.

public

Returns:
boolean

Implements IBackend.

Definition at line 73 of file vcarddir.php.

                             {
        return true;
    }
BackendVCardDir::Logon ( username,
domain,
password 
)


default backend methods

Authenticates the user - NOT EFFECTIVELY IMPLEMENTED Normally some kind of password check would be done here. Alternatively, the password could be ignored and an Apache authentication via mod_auth_* could be done

Parameters:
string$username
string$domain
string$passwordpublic
Returns:
boolean

Implements IBackend.

Definition at line 63 of file vcarddir.php.

                                                         {
        return true;
    }
BackendDiff::MeetingResponse ( requestid,
folderid,
response 
) [inherited]

Processes a response to a meeting request.

CalendarID is a reference and has to be set if a new calendar item is created

Parameters:
string$requestidid of the object containing the request
string$folderidid of the parent folder of $requestid
string$responsepublic
Returns:
string id of the created/updated calendar obj
Exceptions:
StatusException

Implements IBackend.

Definition at line 171 of file diffbackend.php.

                                                                      {
        throw new StatusException(sprintf("BackendDiff->MeetingResponse('%s','%s','%s'): Error, this functionality is not supported by the diff backend", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_MAILBOXERROR);
    }
BackendVCardDir::MoveMessage ( folderid,
id,
newfolderid 
)

Called when the user moves an item on the PDA from one folder to another not implemented.

Parameters:
string$folderidid of the source folder
string$idid of the message
string$newfolderidid of the destination folder

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_MOVEITEMSSTATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 620 of file vcarddir.php.

                                                              {
        return false;
    }
Backend::SaveStorages ( ) [protected, inherited]

Saves the permanent and state related storage data of the user and device if they were loaded previousily If the backend storage is used this should be called.

protected

Returns:

Definition at line 261 of file backend.php.

                                      {
        if (isset($this->permanentStorage)) {
            try {
                ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->permanentStorage, StateManager::BACKENDSTORAGE_PERMANENT);
            }
            catch (StateNotYetAvailableException $snyae) { }
            catch(StateNotFoundException $snfe) { }
        }
        if (isset($this->stateStorage)) {
            try {
                $this->storage_state = ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->stateStorage, StateManager::BACKENDSTORAGE_STATE);
            }
            catch (StateNotYetAvailableException $snyae) { }
            catch(StateNotFoundException $snfe) { }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Sends an e-mail Not implemented here.

Parameters:
SyncSendMail$smSyncSendMail object

public

Returns:
boolean
Exceptions:
StatusException

Implements IBackend.

Definition at line 87 of file vcarddir.php.

                                  {
        return false;
    }
BackendVCardDir::SetReadFlag ( folderid,
id,
flags 
)

Changes the 'read' flag of a message on disk.

Parameters:
string$folderidid of the folder
string$idid of the message
int$flagsread flag of the message

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented from BackendDiff.

Definition at line 590 of file vcarddir.php.

                                                        {
        return false;
    }
Backend::Settings ( settings) [inherited]

Applies settings to and gets informations from the device.

Parameters:
SyncObject$settings(SyncOOF or SyncUserInformation possible)

public

Returns:
SyncObject $settings

Implements IBackend.

Definition at line 185 of file backend.php.

                                        {
        if ($settings instanceof SyncOOF || $settings instanceof SyncUserInformation)
            $settings->Status = SYNC_SETTINGSSTATUS_SUCCESS;
        return $settings;
    }
BackendDiff::Setup ( store,
checkACLonly = false,
folderid = false 
) [inherited]

Setup the backend to work on a specific store or checks ACLs there.

If only the $store is submitted, all Import/Export/Fetch/Etc operations should be performed on this store (switch operations store). If the ACL check is enabled, this operation should just indicate the ACL status on the submitted store, without changing the store for operations. For the ACL status, the currently logged on user MUST have access rights on

  • the entire store - admin access if no folderid is sent, or
  • on a specific folderid in the store (secretary/full access rights)

The ACLcheck MUST fail if a folder of the authenticated user is checked!

Parameters:
string$storetarget store, could contain a "domain\user" value
boolean$checkACLonlyif set to true, Setup() should just check ACLs
string$folderidif set, only ACLs on this folderid are relevant

public

Returns:
boolean

Implements IBackend.

Reimplemented in BackendKolab.

Definition at line 85 of file diffbackend.php.

                                                                            {
        $this->store = $store;

        return true;
    }

Returns folder stats.

An associative array with properties is expected.

Parameters:
string$idid of the folder

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 164 of file vcarddir.php.

                                    {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::StatFolder('.$id.')');
        $folder = $this->GetFolder($id);

        $stat = array();
        $stat["id"] = $id;
        $stat["parent"] = $folder->parentid;
        $stat["mod"] = $folder->displayname;

        return $stat;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendVCardDir::StatMessage ( folderid,
id 
)

Returns message stats, analogous to the folder stats from StatFolder().

Parameters:
string$folderidid of the folder
string$idid of the message

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 475 of file vcarddir.php.

                                                {
        ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::StatMessage('.$folderid.', '.$id.')');
        if($folderid != "root")
            return false;

        $stat = stat($this->getPath() . "/" . $id);

        $message = array();
        $message["mod"] = $stat["mtime"];
        $message["id"] = $id;
        $message["flags"] = 1;

        return $message;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Un-escapes a string.

Parameters:
string$datastring to be un-escaped

private

Returns:
string

Definition at line 668 of file vcarddir.php.

                            {
        $data = str_replace(array('\\\\', '\\;', '\\,', '\\n','\\N'),array('\\', ';', ',', "\n", "\n"),$data);
        return $data;
    }

Here is the caller graph for this function:


Member Data Documentation

Backend::$permanentStorage [protected, inherited]

Definition at line 59 of file backend.php.

Backend::$stateStorage [protected, inherited]

Definition at line 60 of file backend.php.

BackendDiff::$store [protected, inherited]

Definition at line 64 of file diffbackend.php.


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