Back to index

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

List of all members.

Public Member Functions

 SyncMeetingRequestRecurrence ()
 SyncObject ($mapping)
 emptySupported ($supportedFields)
 Sets all supported but not transmitted variables of this SyncObject to an "empty" value, so they are deleted when being saved.
 equals ($odo, $log=false)
 Compares this a SyncObject to another.
 __toString ()
 String representation of the object.
 getUnsetVars ()
 Returns the properties which have to be unset on the server.
 Check ($logAsDebug=false)
 Method checks if the object has the minimum of required parameters and fullfills semantic dependencies.
 Streamer ($mapping)
 Constructor.
 Decode (&$decoder)
 Decodes the WBXML from a WBXMLdecoder until we reach the same depth level of WBXML.
 Encode (&$encoder)
 Encodes this object and any subobjects - output is ordered according to mapping.
 StripData ()
 Removes not necessary data from the object.
 serialize ()
 Method to serialize a Streamer and respective SyncObject.
 unserialize ($data)
 Method to unserialize a Streamer and respective SyncObject.
 parseDate ($ts)
 Transforms an AS timestamp into a unix timestamp.

Public Attributes

 $type
 $until
 $occurrences
 $interval
 $dayofweek
 $dayofmonth
 $weekofmonth
 $monthofyear
const STREAMER_CHECKS = 6
const STREAMER_CHECK_REQUIRED = 7
const STREAMER_CHECK_ZEROORONE = 8
const STREAMER_CHECK_NOTALLOWED = 9
const STREAMER_CHECK_ONEVALUEOF = 10
const STREAMER_CHECK_SETZERO = "setToValue0"
const STREAMER_CHECK_SETONE = "setToValue1"
const STREAMER_CHECK_SETTWO = "setToValue2"
const STREAMER_CHECK_SETEMPTY = "setToValueEmpty"
const STREAMER_CHECK_CMPLOWER = 13
const STREAMER_CHECK_CMPHIGHER = 14
const STREAMER_CHECK_LENGTHMAX = 15
const STREAMER_CHECK_EMAIL = 16
const STREAMER_VAR = 1
const STREAMER_ARRAY = 2
const STREAMER_TYPE = 3
const STREAMER_PROP = 4
const STREAMER_TYPE_DATE = 1
const STREAMER_TYPE_HEX = 2
const STREAMER_TYPE_DATE_DASHES = 3
const STREAMER_TYPE_STREAM = 4
const STREAMER_TYPE_IGNORE = 5
const STREAMER_TYPE_SEND_EMPTY = 6
const STREAMER_TYPE_NO_CONTAINER = 7
const STREAMER_TYPE_COMMA_SEPARATED = 8
const STREAMER_TYPE_SEMICOLON_SEPARATED = 9
 $flags
 $content

Protected Attributes

 $unsetVars
 $mapping

Detailed Description

Definition at line 50 of file syncmeetingrequestrecurrence.php.


Member Function Documentation

SyncObject::__toString ( ) [inherited]

String representation of the object.

Returns:
String

Definition at line 161 of file syncobject.php.

                                 {
        $str = get_class($this) . " (\n";

        $streamerVars = array();
        foreach ($this->mapping as $k=>$v)
            $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;

        foreach (get_object_vars($this) as $k=>$v) {
            if ($k == "mapping") continue;

            if (array_key_exists($k, $streamerVars))
                $strV = "(S) ";
            else
                $strV = "";

            // self::STREAMER_ARRAY ?
            if (is_array($v)) {
                $str .= "\t". $strV . $k ."(Array) size: " . count($v) ."\n";
                foreach ($v as $value) $str .= "\t\t". Utils::PrintAsString($value) ."\n";
            }
            else if ($v instanceof SyncObject) {
                $str .= "\t". $strV .$k ." => ". str_replace("\n", "\n\t\t\t", $v->__toString()) . "\n";
            }
            else
                $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
        }
        $str .= ")";

        return $str;
    }

Here is the call graph for this function:

SyncObject::Check ( logAsDebug = false) [inherited]

Method checks if the object has the minimum of required parameters and fullfills semantic dependencies.

General checks: STREAMER_CHECK_REQUIRED may have as value false (do not fix, ignore object!) or set-to-values: STREAMER_CHECK_SETZERO/ONE/TWO, STREAMER_CHECK_SETEMPTY STREAMER_CHECK_ZEROORONE may be 0 or 1, if none of these, set-to-values: STREAMER_CHECK_SETZERO or STREAMER_CHECK_SETONE STREAMER_CHECK_NOTALLOWED fails if is set STREAMER_CHECK_ONEVALUEOF expects an array with accepted values, fails if value is not in array

Comparison: STREAMER_CHECK_CMPLOWER compares if the current parameter is lower as a literal or another parameter of the same object STREAMER_CHECK_CMPHIGHER compares if the current parameter is higher as a literal or another parameter of the same object

Parameters:
boolean$logAsDebug(opt) default is false, so messages are logged in WARN log level

public

Returns:
boolean

Reimplemented in SyncAppointment, SyncTask, and SyncTaskRecurrence.

Definition at line 221 of file syncobject.php.

                                               {
        $defaultLogLevel = LOGLEVEL_WARN;

        // in some cases non-false checks should not provoke a WARN log but only a DEBUG log
        if ($logAsDebug)
            $defaultLogLevel = LOGLEVEL_DEBUG;

        $objClass = get_class($this);
        foreach ($this->mapping as $k=>$v) {

            // check sub-objects recursively
            if (isset($v[self::STREAMER_TYPE]) && isset($this->$v[self::STREAMER_VAR])) {
                if ($this->$v[self::STREAMER_VAR] instanceof SyncObject) {
                    if (! $this->$v[self::STREAMER_VAR]->Check($logAsDebug))
                        return false;
                }
                else if (is_array($this->$v[self::STREAMER_VAR])) {
                    foreach ($this->$v[self::STREAMER_VAR] as $subobj)
                        if ($subobj instanceof SyncObject && !$subobj->Check($logAsDebug))
                            return false;
                }
            }

            if (isset($v[self::STREAMER_CHECKS])) {
                foreach ($v[self::STREAMER_CHECKS] as $rule => $condition) {
                    // check REQUIRED settings
                    if ($rule === self::STREAMER_CHECK_REQUIRED && (!isset($this->$v[self::STREAMER_VAR]) || $this->$v[self::STREAMER_VAR] === '' ) ) {
                        // parameter is not set but ..
                        // requested to set to 0
                        if ($condition === self::STREAMER_CHECK_SETZERO) {
                            $this->$v[self::STREAMER_VAR] = 0;
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to 0", $objClass, $v[self::STREAMER_VAR]));
                        }
                        // requested to be set to 1
                        else if ($condition === self::STREAMER_CHECK_SETONE) {
                            $this->$v[self::STREAMER_VAR] = 1;
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to 1", $objClass, $v[self::STREAMER_VAR]));
                        }
                        // requested to be set to 2
                        else if ($condition === self::STREAMER_CHECK_SETTWO) {
                            $this->$v[self::STREAMER_VAR] = 2;
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to 2", $objClass, $v[self::STREAMER_VAR]));
                        }
                        // requested to be set to ''
                        else if ($condition === self::STREAMER_CHECK_SETEMPTY) {
                            if (!isset($this->$v[self::STREAMER_VAR])) {
                                $this->$v[self::STREAMER_VAR] = '';
                                ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to ''", $objClass, $v[self::STREAMER_VAR]));
                            }
                        }
                        // there is another value !== false
                        else if ($condition !== false) {
                            $this->$v[self::STREAMER_VAR] = $condition;
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to '%s'", $objClass, $v[self::STREAMER_VAR], $condition));

                        }
                        // no fix available!
                        else {
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter '%s' is required but not set. Check failed!", $objClass, $v[self::STREAMER_VAR]));
                            return false;
                        }
                    } // end STREAMER_CHECK_REQUIRED


                    // check STREAMER_CHECK_ZEROORONE
                    if ($rule === self::STREAMER_CHECK_ZEROORONE && isset($this->$v[self::STREAMER_VAR])) {
                        if ($this->$v[self::STREAMER_VAR] != 0 && $this->$v[self::STREAMER_VAR] != 1) {
                            $newval = $condition === self::STREAMER_CHECK_SETZERO ? 0:1;
                            $this->$v[self::STREAMER_VAR] = $newval;
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to '%s' as it was not 0 or 1", $objClass, $v[self::STREAMER_VAR], $newval));
                        }
                    }// end STREAMER_CHECK_ZEROORONE


                    // check STREAMER_CHECK_ONEVALUEOF
                    if ($rule === self::STREAMER_CHECK_ONEVALUEOF && isset($this->$v[self::STREAMER_VAR])) {
                        if (!in_array($this->$v[self::STREAMER_VAR], $condition)) {
                            ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): object from type %s: parameter '%s'->'%s' is not in the range of allowed values.", $objClass, $v[self::STREAMER_VAR], $this->$v[self::STREAMER_VAR]));
                            return false;
                        }
                    }// end STREAMER_CHECK_ONEVALUEOF


                    // Check value compared to other value or literal
                    if ($rule === self::STREAMER_CHECK_CMPHIGHER || $rule === self::STREAMER_CHECK_CMPLOWER) {
                        if (isset($this->$v[self::STREAMER_VAR])) {
                            $cmp = false;
                            // directly compare against literals
                            if (is_int($condition)) {
                                $cmp = $condition;
                            }
                            // check for invalid compare-to
                            else if (!isset($this->mapping[$condition])) {
                                ZLog::Write(LOGLEVEL_ERROR, sprintf("SyncObject->Check(): Can not compare parameter '%s' against the other value '%s' as it is not defined object from type %s. Please report this! Check skipped!", $objClass, $v[self::STREAMER_VAR], $condition));
                                continue;
                            }
                            else {
                                $cmpPar = $this->mapping[$condition][self::STREAMER_VAR];
                                if (isset($this->$cmpPar))
                                    $cmp = $this->$cmpPar;
                            }

                            if ($cmp === false) {
                                ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter '%s' can not be compared, as the comparable is not set. Check failed!", $objClass, $v[self::STREAMER_VAR]));
                                return false;
                            }
                            if ( ($rule == self::STREAMER_CHECK_CMPHIGHER && $this->$v[self::STREAMER_VAR] < $cmp) ||
                                 ($rule == self::STREAMER_CHECK_CMPLOWER  && $this->$v[self::STREAMER_VAR] > $cmp)
                                ) {

                                ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter '%s' is %s than '%s'. Check failed!",
                                                                    $objClass,
                                                                    $v[self::STREAMER_VAR],
                                                                    (($rule === self::STREAMER_CHECK_CMPHIGHER)?'LOWER':'HIGHER'),
                                                                    ((isset($cmpPar)?$cmpPar:$condition))  ));
                                return false;
                            }
                        }
                    } // STREAMER_CHECK_CMP*


                    // check STREAMER_CHECK_LENGTHMAX
                    if ($rule === self::STREAMER_CHECK_LENGTHMAX && isset($this->$v[self::STREAMER_VAR])) {

                        if (is_array($this->$v[self::STREAMER_VAR])) {
                            // implosion takes 2bytes, so we just assume ", " here
                            $chkstr = implode(", ", $this->$v[self::STREAMER_VAR]);
                        }
                        else
                            $chkstr = $this->$v[self::STREAMER_VAR];

                        if (strlen($chkstr) > $condition) {
                            ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' is longer than %d. Check failed", $objClass, $v[self::STREAMER_VAR], $condition));
                            return false;
                        }
                    }// end STREAMER_CHECK_LENGTHMAX


                    // check STREAMER_CHECK_EMAIL
                    // if $condition is false then the check really fails. Otherwise invalid emails are removed.
                    // if nothing is left (all emails were false), the parameter is set to condition
                    if ($rule === self::STREAMER_CHECK_EMAIL && isset($this->$v[self::STREAMER_VAR])) {
                        if ($condition === false && ( (is_array($this->$v[self::STREAMER_VAR]) && empty($this->$v[self::STREAMER_VAR])) || strlen($this->$v[self::STREAMER_VAR]) == 0) )
                            continue;

                        $as_array = false;

                        if (is_array($this->$v[self::STREAMER_VAR])) {
                            $mails = $this->$v[self::STREAMER_VAR];
                            $as_array = true;
                        }
                        else {
                            $mails = array( $this->$v[self::STREAMER_VAR] );
                        }

                        $output = array();
                        foreach ($mails as $mail) {
                            if (! Utils::CheckEmail($mail)) {
                                ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' contains an invalid email address '%s'. Address is removed.", $objClass, $v[self::STREAMER_VAR], $mail));
                            }
                            else
                                $output[] = $mail;
                        }
                        if (count($mails) != count($output)) {
                            if ($condition === false)
                                return false;

                            // nothing left, use $condition as new value
                            if (count($output) == 0)
                                $output[] = $condition;

                            // if we are allowed to rewrite the attribute, we do that
                            if ($as_array)
                                $this->$v[self::STREAMER_VAR] = $output;
                            else
                                $this->$v[self::STREAMER_VAR] = $output[0];
                        }
                    }// end STREAMER_CHECK_EMAIL


                } // foreach CHECKS
            } // isset CHECKS
        } // foreach mapping

        return true;
    }

Here is the call graph for this function:

Streamer::Decode ( &$  decoder) [inherited]

Decodes the WBXML from a WBXMLdecoder until we reach the same depth level of WBXML.

This means that if there are multiple objects at this level, then only the first is decoded SubOjects are auto-instantiated and decoded using the same functionality

Parameters:
WBXMLDecoder$decoderpublic

Definition at line 89 of file streamer.php.

                                      {
        while(1) {
            $entity = $decoder->getElement();

            if($entity[EN_TYPE] == EN_TYPE_STARTTAG) {
                if(! ($entity[EN_FLAGS] & EN_FLAGS_CONTENT)) {
                    $map = $this->mapping[$entity[EN_TAG]];
                    if (isset($map[self::STREAMER_ARRAY])) {
                        $this->$map[self::STREAMER_VAR] = array();
                    } else if(!isset($map[self::STREAMER_TYPE])) {
                        $this->$map[self::STREAMER_VAR] = "";
                    }
                    else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) {
                        $this->$map[self::STREAMER_VAR] = "";
                    }
                    else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEND_EMPTY)
                        $this->$map[self::STREAMER_VAR] = "";
                    else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY)
                        $this->$map[self::STREAMER_VAR] = "";
                    continue;
                }
                // Found a start tag
                if(!isset($this->mapping[$entity[EN_TAG]])) {
                    // This tag shouldn't be here, abort
                    ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Tag '%s' unexpected in type XML type '%s'", $entity[EN_TAG], get_class($this)));
                    return false;
                }
                else {
                    $map = $this->mapping[$entity[EN_TAG]];

                    // Handle an array
                    if(isset($map[self::STREAMER_ARRAY])) {
                        while(1) {
                            //do not get start tag for an array without a container
                            if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) {
                                if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY]))
                                    break;
                            }
                            if(isset($map[self::STREAMER_TYPE])) {
                                $decoded = new $map[self::STREAMER_TYPE];

                                $decoded->Decode($decoder);
                            }
                            else {
                                $decoded = $decoder->getElementContent();
                            }

                            if(!isset($this->$map[self::STREAMER_VAR]))
                                $this->$map[self::STREAMER_VAR] = array($decoded);
                            else
                                array_push($this->$map[self::STREAMER_VAR], $decoded);

                            if(!$decoder->getElementEndTag()) //end tag of a container element
                                return false;

                            if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER) {
                                $e = $decoder->peek();
                                //go back to the initial while if another block of no container elements is found
                                if ($e[EN_TYPE] == EN_TYPE_STARTTAG) {
                                    continue 2;
                                }
                                //break on end tag because no container elements block end is reached
                                if ($e[EN_TYPE] == EN_TYPE_ENDTAG)
                                    break;
                                if (empty($e))
                                    break;
                            }
                        }
                        //do not get end tag for an array without a container
                        if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) {
                            if(!$decoder->getElementEndTag()) //end tag of container
                                return false;
                        }
                    }
                    else { // Handle single value
                        if(isset($map[self::STREAMER_TYPE])) {
                            // Complex type, decode recursively
                            if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) {
                                $decoded = $this->parseDate($decoder->getElementContent());
                                if(!$decoder->getElementEndTag())
                                    return false;
                            }
                            else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
                                $decoded = hex2bin($decoder->getElementContent());
                                if(!$decoder->getElementEndTag())
                                    return false;
                            }
                            else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEND_EMPTY) {
                                $decoded = $decoder->getElementContent();
                                if(!$decoder->getElementEndTag())
                                    return false;
                            }
                            else {
                                $subdecoder = new $map[self::STREAMER_TYPE]();
                                if($subdecoder->Decode($decoder) === false)
                                    return false;

                                $decoded = $subdecoder;

                                if(!$decoder->getElementEndTag()) {
                                    ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("No end tag for '%s'", $entity[EN_TAG]));
                                    return false;
                                }
                            }
                        }
                        else {
                            // Simple type, just get content
                            $decoded = $decoder->getElementContent();

                            if($decoded === false) {
                                // the tag is declared to have content, but no content is available.
                                // set an empty content
                                $decoded = "";
                            }

                            if(!$decoder->getElementEndTag()) {
                                ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Unable to get end tag for '%s'", $entity[EN_TAG]));
                                return false;
                            }
                        }
                        // $decoded now contains data object (or string)
                        $this->$map[self::STREAMER_VAR] = $decoded;
                    }
                }
            }
            else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) {
                $decoder->ungetElement($entity);
                break;
            }
            else {
                ZLog::Write(LOGLEVEL_WBXMLSTACK, "Unexpected content in type");
                break;
            }
        }
    }

Here is the call graph for this function:

SyncObject::emptySupported ( supportedFields) [inherited]

Sets all supported but not transmitted variables of this SyncObject to an "empty" value, so they are deleted when being saved.

Parameters:
array$supportedFieldsarray with all supported fields, if available

public

Returns:
boolean

Definition at line 82 of file syncobject.php.

                                                     {
        if ($supportedFields === false || !is_array($supportedFields))
            return false;

        foreach ($supportedFields as $field) {
            if (!isset($this->mapping[$field])) {
                ZLog::Write(LOGLEVEL_WARN, sprintf("Field '%s' is supposed to be emptied but is not defined for '%s'", $field, get_class($this)));
                continue;
            }
            $var = $this->mapping[$field][self::STREAMER_VAR];
            // add var to $this->unsetVars if $var is not set
            if (!isset($this->$var))
                $this->unsetVars[] = $var;
        }
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Supported variables to be unset: %s", implode(',', $this->unsetVars)));
        return true;
    }

Here is the call graph for this function:

Streamer::Encode ( &$  encoder) [inherited]

Encodes this object and any subobjects - output is ordered according to mapping.

Parameters:
WBXMLEncoder$encoderpublic

Definition at line 232 of file streamer.php.

                                      {
        foreach($this->mapping as $tag => $map) {
            if(isset($this->$map[self::STREAMER_VAR])) {
                // Variable is available
                if(is_object($this->$map[self::STREAMER_VAR])) {
                    // Subobjects can do their own encoding
                    if ($this->$map[self::STREAMER_VAR] instanceof Streamer) {
                        $encoder->startTag($tag);
                        $this->$map[self::STREAMER_VAR]->Encode($encoder);
                        $encoder->endTag();
                    }
                    else
                        ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this)));
                }
                // Array of objects
                else if(isset($map[self::STREAMER_ARRAY])) {
                    if ((empty($this->$map[self::STREAMER_VAR]) && isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEND_EMPTY)
                    || (isset($map[self::STREAMER_PROP]) &&  isset($map[self::STREAMER_PROP]) == self::STREAMER_TYPE_SEND_EMPTY)) {
                        $encoder->startTag($tag, false, true);
                    }
                    else {
                        // Outputs array container (eg Attachments)
                        // Do not output start and end tag when type is STREAMER_TYPE_NO_CONTAINER
                        if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER)
                            $encoder->startTag($tag);

                        foreach ($this->$map[self::STREAMER_VAR] as $element) {
                            if(is_object($element)) {
                                $encoder->startTag($map[self::STREAMER_ARRAY]); // Outputs object container (eg Attachment)
                                $element->Encode($encoder);
                                $encoder->endTag();
                            }
                            else {
                                if(strlen($element) == 0)
                                      // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true);
                                      ;
                                else {
                                    $encoder->startTag($map[self::STREAMER_ARRAY]);
                                    $encoder->content($element);
                                    $encoder->endTag();
                                }
                            }
                        }

                        if  (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER)
                            $encoder->endTag();
                    }
                }
                else {
                    if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) {
                        continue;
                    }

                    // Simple type
                    if(!isset($map[self::STREAMER_TYPE]) && strlen($this->$map[self::STREAMER_VAR]) == 0) {
                        if ((isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEND_EMPTY)
                        || (isset($map[self::STREAMER_PROP]) &&  isset($map[self::STREAMER_PROP]) == self::STREAMER_TYPE_SEND_EMPTY)) {
                            $encoder->startTag($tag, false, true);
                        }
                          // Do not output empty items. See above: $encoder->startTag($tag, false, true);
                        continue;
                    } else
                        $encoder->startTag($tag);

                    if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) {
                        if($this->$map[self::STREAMER_VAR] != 0) // don't output 1-1-1970
                            $encoder->content($this->formatDate($this->$map[self::STREAMER_VAR], $map[self::STREAMER_TYPE]));
                    }
                    else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
                        $encoder->content(strtoupper(bin2hex($this->$map[self::STREAMER_VAR])));
                    }
                    else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM) {
                        //encode stream with base64
                        //TODO stream chunked without loading the complete attachment into memory
                        $stream = $this->$map[self::STREAMER_VAR];
                        $base64filter = stream_filter_append($stream, 'convert.base64-encode');
                        $d = "";
                        while (!feof($stream)) {
                            $d .= fgets($stream, 4096);
                        }
                        $encoder->content($d);
                        stream_filter_remove($base64filter);
                    }
                    // implode comma or semicolon arrays into a string
                    else if(isset($map[self::STREAMER_TYPE]) && is_array($this->$map[self::STREAMER_VAR]) &&
                        ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED)) {
                        $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; ";
                        $encoder->content(implode($glue, $this->$map[self::STREAMER_VAR]));
                    }
                    else {
                        $encoder->content($this->$map[self::STREAMER_VAR]);
                    }
                    $encoder->endTag();
                }
            }
        }
        // Output our own content
        if(isset($this->content))
            $encoder->content($this->content);
    }

Here is the call graph for this function:

SyncObject::equals ( odo,
log = false 
) [inherited]

Compares this a SyncObject to another.

In case that all available mapped fields are exactly EQUAL, it returns true

See also:
SyncObject
Parameters:
SyncObject$odoother SyncObject
Returns:
boolean

Definition at line 109 of file syncobject.php.

                                               {
        if ($odo === false)
            return false;

        // check objecttype
        if (! ($odo instanceof SyncObject)) {
            ZLog::Write(LOGLEVEL_DEBUG, "SyncObject->equals() the target object is not a SyncObject");
            return false;
        }

        // check for mapped fields
        foreach ($this->mapping as $v) {
            $val = $v[self::STREAMER_VAR];
            // array of values?
            if (isset($v[self::STREAMER_ARRAY])) {
                // seek for differences in the arrays
                if (is_array($this->$val) && is_array($odo->$val)) {
                    if (count(array_diff($this->$val, $odo->$val)) + count(array_diff($odo->$val, $this->$val)) > 0) {
                        ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() items in array '%s' differ", $val));
                        return false;
                    }
                }
                else {
                    ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() array '%s' is set in one but not the other object", $val));
                    return false;
                }
            }
            else {
                if (isset($this->$val) && isset($odo->$val)) {
                    if ($this->$val != $odo->$val){
                        ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false on field '%s': '%s' != '%s'", $val, Utils::PrintAsString($this->$val), Utils::PrintAsString($odo->$val)));
                        return false;
                    }
                }
                else if (!isset($this->$val) && !isset($odo->$val)) {
                    continue;
                }
                else {
                    ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false because field '%s' is only defined at one obj: '%s' != '%s'", $val, Utils::PrintAsString(isset($this->$val)), Utils::PrintAsString(isset($odo->$val))));
                    return false;
                }
            }
        }

        return true;
    }

Here is the call graph for this function:

SyncObject::getUnsetVars ( ) [inherited]

Returns the properties which have to be unset on the server.

public

Returns:
array

Definition at line 198 of file syncobject.php.

                                   {
        return $this->unsetVars;
    }
Streamer::parseDate ( ts) [inherited]

Transforms an AS timestamp into a unix timestamp.

Parameters:
string$tsprivate
Returns:
long

Definition at line 423 of file streamer.php.

                            {
        if(preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) {
            if ($matches[1] >= 2038){
                $matches[1] = 2038;
                $matches[2] = 1;
                $matches[3] = 18;
                $matches[5] = $matches[6] = $matches[7] = 0;
            }

            if (!isset($matches[5])) $matches[5] = 0;
            if (!isset($matches[6])) $matches[6] = 0;
            if (!isset($matches[7])) $matches[7] = 0;

            return gmmktime($matches[5], $matches[6], $matches[7], $matches[2], $matches[3], $matches[1]);
        }
        return 0;
    }

Here is the caller graph for this function:

Streamer::serialize ( ) [inherited]

Method to serialize a Streamer and respective SyncObject.

public

Returns:
array

Definition at line 365 of file streamer.php.

                                {
        $values = array();
        foreach ($this->mapping as $k=>$v) {
            if (isset($this->$v[self::STREAMER_VAR]))
                $values[$v[self::STREAMER_VAR]] = serialize($this->$v[self::STREAMER_VAR]);
        }

        return serialize($values);
    }
Streamer::Streamer ( mapping) [inherited]

Constructor.

Parameters:
array$mappinginternal mapping of variables public

Definition at line 75 of file streamer.php.

                                {
        $this->mapping = $mapping;
        $this->flags = false;
    }

Here is the caller graph for this function:

Streamer::StripData ( ) [inherited]

Removes not necessary data from the object.

public

Returns:
boolean

Definition at line 339 of file streamer.php.

                                {
        foreach ($this->mapping as $k=>$v) {
            if (isset($this->$v[self::STREAMER_VAR])) {
                if (is_object($this->$v[self::STREAMER_VAR]) && method_exists($this->$v[self::STREAMER_VAR], "StripData") ) {
                    $this->$v[self::STREAMER_VAR]->StripData();
                }
                else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->$v[self::STREAMER_VAR])) {
                    foreach ($this->$v[self::STREAMER_VAR] as $element) {
                        if (is_object($element) && method_exists($element, "StripData") ) {
                            $element->StripData();
                        }
                    }
                }
            }
        }
        unset($this->mapping);

        return true;
    }

Definition at line 60 of file syncmeetingrequestrecurrence.php.

                                            {
        $mapping = array (
                    // Recurrence type
                    // 0 = Recurs daily
                    // 1 = Recurs weekly
                    // 2 = Recurs monthly
                    // 3 = Recurs monthly on the nth day
                    // 5 = Recurs yearly
                    // 6 = Recurs yearly on the nth day
                    SYNC_POOMMAIL_TYPE                                  => array (  self::STREAMER_VAR      => "type",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => self::STREAMER_CHECK_SETZERO,
                                                                                                                        self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,5,6) )),

                    SYNC_POOMMAIL_UNTIL                                 => array (  self::STREAMER_VAR      => "until",
                                                                                    self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE),

                    SYNC_POOMMAIL_OCCURRENCES                           => array (  self::STREAMER_VAR      => "occurrences",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
                                                                                                                        self::STREAMER_CHECK_CMPLOWER   => 1000 )),

                    SYNC_POOMMAIL_INTERVAL                              => array (  self::STREAMER_VAR      => "interval",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
                                                                                                                        self::STREAMER_CHECK_CMPLOWER   => 1000 )),

                    // DayOfWeek values
                    //   1 = Sunday
                    //   2 = Monday
                    //   4 = Tuesday
                    //   8 = Wednesday
                    //  16 = Thursday
                    //  32 = Friday
                    //  62 = Weekdays  // TODO check: value set by WA with daily weekday recurrence
                    //  64 = Saturday
                    // 127 = The last day of the month. Value valid only in monthly or yearly recurrences.
                    SYNC_POOMMAIL_DAYOFWEEK                             => array (  self::STREAMER_VAR      => "dayofweek",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,4,8,16,32,62,64,127) )),

                    // DayOfMonth values
                    // 1-31 representing the day
                    SYNC_POOMMAIL_DAYOFMONTH                            => array (  self::STREAMER_VAR      => "dayofmonth",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
                                                                                                                        self::STREAMER_CHECK_CMPLOWER   => 32 )),

                    // WeekOfMonth
                    // 1-4 = Y st/nd/rd/th week of month
                    // 5 = last week of month
                    SYNC_POOMMAIL_WEEKOFMONTH                           => array (  self::STREAMER_VAR      => "weekofmonth",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5) )),

                    // MonthOfYear
                    // 1-12 representing the month
                    SYNC_POOMMAIL_MONTHOFYEAR                           => array (  self::STREAMER_VAR      => "monthofyear",
                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5,6,7,8,9,10,11,12) )),
                );

        parent::SyncObject($mapping);
    }

Here is the call graph for this function:

SyncObject::SyncObject ( mapping) [inherited]

Definition at line 68 of file syncobject.php.

                                         {
        $this->unsetVars = array();
        parent::Streamer($mapping);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Streamer::unserialize ( data) [inherited]

Method to unserialize a Streamer and respective SyncObject.

public

Returns:
array

Definition at line 381 of file streamer.php.

                                       {
        $class = get_class($this);
        $this->$class();
        $values = unserialize($data);
        foreach ($values as $k=>$v)
            $this->$k = unserialize($v);

        return true;
    }

Member Data Documentation

Streamer::$content [inherited]

Definition at line 67 of file streamer.php.

Definition at line 56 of file syncmeetingrequestrecurrence.php.

Definition at line 55 of file syncmeetingrequestrecurrence.php.

Streamer::$flags [inherited]

Definition at line 66 of file streamer.php.

Definition at line 54 of file syncmeetingrequestrecurrence.php.

Streamer::$mapping [protected, inherited]

Definition at line 65 of file streamer.php.

Definition at line 58 of file syncmeetingrequestrecurrence.php.

Definition at line 53 of file syncmeetingrequestrecurrence.php.

Definition at line 51 of file syncmeetingrequestrecurrence.php.

SyncObject::$unsetVars [protected, inherited]

Definition at line 65 of file syncobject.php.

Definition at line 52 of file syncmeetingrequestrecurrence.php.

Definition at line 57 of file syncmeetingrequestrecurrence.php.

const Streamer::STREAMER_ARRAY = 2 [inherited]

Definition at line 52 of file streamer.php.

const SyncObject::STREAMER_CHECK_CMPHIGHER = 14 [inherited]

Definition at line 61 of file syncobject.php.

const SyncObject::STREAMER_CHECK_CMPLOWER = 13 [inherited]

Definition at line 60 of file syncobject.php.

const SyncObject::STREAMER_CHECK_EMAIL = 16 [inherited]

Definition at line 63 of file syncobject.php.

const SyncObject::STREAMER_CHECK_LENGTHMAX = 15 [inherited]

Definition at line 62 of file syncobject.php.

Definition at line 54 of file syncobject.php.

const SyncObject::STREAMER_CHECK_ONEVALUEOF = 10 [inherited]

Definition at line 55 of file syncobject.php.

const SyncObject::STREAMER_CHECK_REQUIRED = 7 [inherited]

Definition at line 52 of file syncobject.php.

const SyncObject::STREAMER_CHECK_SETEMPTY = "setToValueEmpty" [inherited]

Definition at line 59 of file syncobject.php.

const SyncObject::STREAMER_CHECK_SETONE = "setToValue1" [inherited]

Definition at line 57 of file syncobject.php.

const SyncObject::STREAMER_CHECK_SETTWO = "setToValue2" [inherited]

Definition at line 58 of file syncobject.php.

const SyncObject::STREAMER_CHECK_SETZERO = "setToValue0" [inherited]

Definition at line 56 of file syncobject.php.

const SyncObject::STREAMER_CHECK_ZEROORONE = 8 [inherited]

Definition at line 53 of file syncobject.php.

const SyncObject::STREAMER_CHECKS = 6 [inherited]

Definition at line 51 of file syncobject.php.

const Streamer::STREAMER_PROP = 4 [inherited]

Definition at line 54 of file streamer.php.

const Streamer::STREAMER_TYPE = 3 [inherited]

Definition at line 53 of file streamer.php.

Definition at line 62 of file streamer.php.

const Streamer::STREAMER_TYPE_DATE = 1 [inherited]

Definition at line 55 of file streamer.php.

const Streamer::STREAMER_TYPE_DATE_DASHES = 3 [inherited]

Definition at line 57 of file streamer.php.

const Streamer::STREAMER_TYPE_HEX = 2 [inherited]

Definition at line 56 of file streamer.php.

const Streamer::STREAMER_TYPE_IGNORE = 5 [inherited]

Definition at line 59 of file streamer.php.

const Streamer::STREAMER_TYPE_NO_CONTAINER = 7 [inherited]

Definition at line 61 of file streamer.php.

Definition at line 63 of file streamer.php.

const Streamer::STREAMER_TYPE_SEND_EMPTY = 6 [inherited]

Definition at line 60 of file streamer.php.

const Streamer::STREAMER_TYPE_STREAM = 4 [inherited]

Definition at line 58 of file streamer.php.

const Streamer::STREAMER_VAR = 1 [inherited]

Definition at line 51 of file streamer.php.


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