/**
  * @param object $abc
  */
 public function __construct($abc)
 {
     $this->config = $abc->getConfig();
     $this->router = $abc->getFromStorage('Router');
     $this->request = $abc->getFromStorage('Request');
     $this->parser = $abc->getFromStorage('RouteParser');
 }
Exemple #2
0
 /**
  * Set respective route params with actual value.
  */
 protected function setRouteParams()
 {
     $this->rule = str_replace(')', '', str_replace('(', '', $this->rule));
     $fs = '/';
     if (strpos($this->rule, $fs) !== false && strpos($this->pathInfo, $fs) !== false) {
         $arrUri = explode($fs, $this->rule);
         $arrPathInfo = explode($fs, $this->pathInfo);
         // iterate over and set respective values to token
         for ($i = 0, $len = count($arrUri); $i < $len; $i++) {
             if (!empty($arrPathInfo[$i]) && strpos($arrUri[$i], '@') !== false) {
                 $key = $arrUri[$i];
                 $value = $arrPathInfo[$i];
                 $this->setParam($key, $this->app->escape($value));
             }
         }
     }
     // set directory
     $this->setParam('@directory', $this->app->arrGet('@directory', $this->filters, ''));
     // set default controller if empty
     if (empty($this->getParams('@controller'))) {
         $this->setParam('@controller', $this->app->getConfig('defaultController'));
     }
     // set default action if empty
     if (empty($this->getParams('@action'))) {
         $this->setParam('@action', static::DEFAULT_ACTION);
     }
     return $this;
 }
 /**
  * Конструктор
  *
  * @param object $abc
  */
 public function __construct($abc)
 {
     $this->abc = $abc;
     $driver = $abc->getConfig('db_command')['driver'];
     $this->driver = 'ABC\\Abc\\Components\\DbCommand\\' . $driver;
     $this->command = new $this->driver($this->abc);
     $this->prefix = $this->command->prefix;
 }
 /**
  * Конструктор
  *
  * @param object $abc
  *
  */
 public function __construct($abc)
 {
     $config = $abc->getConfig('mysqli');
     if (!empty($config)) {
         $this->newConnect($config);
     } else {
         AbcError::invalidArgument(' Component Mysqli: ' . ABC_WRONG_CONNECTION);
     }
 }
 /**
  * Constructor
  * 
  * @param object $adapter
  */
 public function __construct($adapter)
 {
     $this->setConfiguration($adapter->getConfig());
     if ($adapter instanceof \Zend_Db_Adapter_Pdo_Mysql) {
         $this->setAdapter(new Db\Mysql($adapter));
     }
     if ($adapter instanceof \Zend_Db_Adapter_Pdo_Pgsql) {
         $this->setAdapter(new Db\Pgsql($adapter));
     }
 }
 /**
  * Check Function
  *
  * This is responsible for checking the driver configuration to determine
  * if the system supports a particular function.
  *
  * @param string $function The name of the function to check.
  *
  * @return mixed On success, an associative array with specific function keys
  * and values; on failure, false.
  * @access public
  */
 public function checkFunction($function)
 {
     // Extract the configuration from the driver if available:
     $functionConfig = method_exists($this->driver, 'getConfig') ? $this->driver->getConfig($function) : false;
     // See if we have a corresponding check method to analyze the response:
     $checkMethod = "_checkMethod" . $function;
     if (!method_exists($this, $checkMethod)) {
         //Just see if the method exists on the driver
         return method_exists($this->driver, $function);
     }
     // Send back the settings:
     return $this->{$checkMethod}($functionConfig);
 }
 /**
  * Check Function
  *
  * This is responsible for checking the driver configuration to determine
  * if the system supports a particular function.
  *
  * @param string $function The name of the function to check.
  * @param string $id       (optional) A record id used to identify the used backend with
  * MultiBackend driver
  *
  * @return mixed On success, an associative array with specific function keys
  * and values; on failure, false.
  * @access public
  */
 public function checkFunction($function, $id = null)
 {
     // Extract the configuration from the driver if available:
     $functionConfig = method_exists($this->driver, 'getConfig') ? $this->driver->getConfig($function, $id) : false;
     if (PEAR::isError($functionConfig)) {
         return false;
     }
     // See if we have a corresponding check method to analyze the response:
     $checkMethod = "_checkMethod" . $function;
     if (!method_exists($this, $checkMethod)) {
         return false;
     }
     // Send back the settings:
     return $this->{$checkMethod}($functionConfig);
 }
 /**
  * Get the configuration display of the authentication driver
  * @param  object $userman The userman object
  * @param  object $freepbx The FreePBX BMO object
  * @return string          html display data
  */
 public static function getConfig($userman, $freepbx)
 {
     $config = $userman->getConfig("authVoicemailSettings");
     $config['context'] = !empty($config['context']) ? $config['context'] : 'default';
     return load_view(dirname(dirname(dirname(__DIR__))) . "/views/voicemail.php", array("config" => $config));
 }
Exemple #9
0
 /**
  * add calendar component as subcomponent to container for subcomponents
  *
  * @author Kjell-Inge Gustafsson <*****@*****.**>
  * @since 2.4.13 - 2008-09-24
  * @param object $component calendar component
  * @param mixed $arg1 optional, ordno/component type/ component uid
  * @param mixed $arg2 optional, ordno if arg1 = component type
  * @return bool
  */
 function setComponent($component, $arg1 = FALSE, $arg2 = FALSE)
 {
     if (!isset($this->components)) {
         return FALSE;
     }
     if ('' >= $component->getConfig('language')) {
         $component->setConfig('language', $this->getConfig('language'));
     }
     $component->setConfig('allowEmpty', $this->getConfig('allowEmpty'));
     $component->setConfig('nl', $this->getConfig('nl'));
     $component->setConfig('unique_id', $this->getConfig('unique_id'));
     $component->setConfig('format', $this->getConfig('format'));
     if (!in_array($component->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) {
         unset($component->propix);
         /* make sure dtstamp and uid is set */
         $dummy = $component->getProperty('dtstamp');
         $dummy = $component->getProperty('uid');
     }
     if (!$arg1) {
         $this->components[] = $component->copy();
         return TRUE;
     }
     $argType = $index = null;
     if (ctype_digit((string) $arg1)) {
         $argType = 'INDEX';
         $index = (int) $arg1 - 1;
     } elseif (strlen($arg1) <= strlen('vfreebusy') && FALSE === strpos($arg1, '@')) {
         $argType = strtolower($arg1);
         $index = ctype_digit((string) $arg2) ? (int) $arg2 - 1 : 0;
     }
     $cix2sC = 0;
     foreach ($this->components as $cix => $component2) {
         if (empty($component2)) {
             continue;
         }
         unset($component2->propix);
         if ('INDEX' == $argType && $index == $cix) {
             $this->components[$cix] = $component->copy();
             return TRUE;
         } elseif ($argType == $component2->objName) {
             if ($index == $cix2sC) {
                 $this->components[$cix] = $component->copy();
                 return TRUE;
             }
             $cix2sC++;
         } elseif (!$argType && $arg1 == $component2->getProperty('uid')) {
             $this->components[$cix] = $component->copy();
             return TRUE;
         }
     }
     /* not found.. . insert anyway.. .*/
     $this->components[] = $component->copy();
     return TRUE;
 }
Exemple #10
0
 /**
  * function iCal2xls
  *
  * Convert iCal file to xls format and send file to browser (default) or save xls file to disk
  * Definition iCal  : rcf2445, http://kigkonsult.se/downloads/index.php#rfc
  * Using iCalcreator: http://kigkonsult.se/downloads/index.php#iCalcreator
  * Based on PEAR Spreadsheet_Excel_Writer-0.9.1 (and OLE-1.0.0RC1)
  * to be installed as
  * pear install channel://pear.php.net/OLE-1.0.0RC1
  * pear install channel://pear.php.net/Spreadsheet_Excel_Writer-0.9.1
  *
  * @author Kjell-Inge Gustafsson <*****@*****.**>
  * @since  3.0 - 2011-12-21
  * @param  object $calendar opt. iCalcreator calendar instance
  * @return bool   returns FALSE when error
  */
 public function iCal2xls($calendar = FALSE)
 {
     $timeexec = array('start' => microtime(TRUE));
     if ($this->log) {
         $this->log->log(' ********** START **********', PEAR_LOG_NOTICE);
     }
     /** check input/output directory and filename */
     $inputdirFile = $outputdirFile = '';
     $inputFileParts = $outputFileParts = array();
     $remoteInput = $remoteOutput = FALSE;
     if ($calendar) {
         $inputdirFile = $calendar->getConfig('DIRFILE');
         $inputFileParts = pathinfo($inputdirFile);
         $inputFileParts['dirname'] = realpath($inputFileParts['dirname']);
         if ($this->log) {
             $this->log->log('fileParts:' . var_export($inputFileParts, TRUE), PEAR_LOG_DEBUG);
         }
     } elseif (FALSE === $this->_fixIO('input', 'ics', $inputdirFile, $inputFileParts, $remoteInput)) {
         if ($this->log) {
             $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR);
             $this->log->log("ERROR 2, invalid input ({$inputdirFile})", PEAR_LOG_ERR);
             $this->log->flush();
         }
         return FALSE;
     }
     if (FALSE === $this->_fixIO('output', FALSE, $outputdirFile, $outputFileParts, $remoteOutput)) {
         if (FALSE === $this->setConfig('outputfilename', $inputFileParts['filename'] . '.xls')) {
             if ($this->log) {
                 $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR);
                 $this->log->log('ERROR 3, invalid output (' . $inputFileParts['filename'] . '.csv)', PEAR_LOG_ERR);
                 $this->log->flush();
             }
             return FALSE;
         }
         $outputdirFile = $this->getConfig('outputdirectory') . DIRECTORY_SEPARATOR . $inputFileParts['filename'] . '.xls';
         $outputFileParts = pathinfo($outputdirFile);
         if ($this->log) {
             $this->log->log("output set to '{$outputdirFile}'", PEAR_LOG_INFO);
         }
     }
     if ($this->log) {
         $this->log->log("INPUT..FILE:{$inputdirFile}", PEAR_LOG_NOTICE);
         $this->log->log("OUTPUT.FILE:{$outputdirFile}", PEAR_LOG_NOTICE);
     }
     $save = $this->getConfig('save');
     if ($calendar) {
         $calnl = $calendar->getConfig('nl');
     } else {
         /** iCalcreator set config, read and parse input iCal file */
         $calendar = new vcalendar();
         if (FALSE !== ($unique_id = $this->getConfig('unique_id'))) {
             $calendar->setConfig('unique_id', $unique_id);
         }
         $calnl = $calendar->getConfig('nl');
         if ($remoteInput) {
             if (FALSE === $calendar->setConfig('url', $inputdirFile)) {
                 if ($this->log) {
                     $this->log->log("ERROR 3 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid url", 3);
                 }
                 return FALSE;
             }
         } else {
             if (FALSE === $calendar->setConfig('directory', $inputFileParts['dirname'])) {
                 if ($this->log) {
                     $this->log->log("ERROR 4 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid directory: '" . $inputFileParts['dirname'] . "'", 3);
                     $this->log->flush();
                 }
                 return FALSE;
             }
             if (FALSE === $calendar->setConfig('filename', $inputFileParts['basename'])) {
                 if ($this->log) {
                     $this->log->log("ERROR 5 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid filename: '" . $inputFileParts['basename'] . "'", 3);
                     $this->log->flush();
                 }
                 return FALSE;
             }
         }
         if (FALSE === $calendar->parse()) {
             if ($this->log) {
                 $this->log->log("ERROR 6 INPUT FILE:'{$inputdirFile}' iCalcreator parse error", 3);
                 $this->log->flush();
             }
             return FALSE;
         }
     }
     // end if( !$calendar )
     $timeexec['fileOk'] = microtime(TRUE);
     if (!function_exists('iCaldate2timestamp')) {
         function iCaldate2timestamp($d)
         {
             if (6 > count($d)) {
                 return mktime(0, 0, 0, $d['month'], $d['day'], $d['year']);
             } else {
                 return mktime($d['hour'], $d['min'], $d['sec'], $d['month'], $d['day'], $d['year']);
             }
         }
     }
     if (!function_exists('fixiCalString')) {
         function fixiCalString($s)
         {
             global $calnl;
             $s = str_replace('\\,', ',', $s);
             $s = str_replace('\\;', ';', $s);
             $s = str_replace('\\n ', chr(10), $s);
             $s = str_replace('\\\\', '\\', $s);
             $s = str_replace("{$calnl}", chr(10), $s);
             return utf8_decode($s);
         }
     }
     /** Creating a workbook */
     require_once 'Spreadsheet/Excel/Writer.php';
     if ($save) {
         $workbook = new Spreadsheet_Excel_Writer($outputdirFile);
     } else {
         $workbook = new Spreadsheet_Excel_Writer();
     }
     $workbook->setVersion(8);
     // Use Excel97/2000 Format
     /** opt. sending HTTP headers */
     if (!$save) {
         $workbook->send($outputFileParts['basename']);
     }
     /** Creating a worksheet */
     $worksheet =& $workbook->addWorksheet($inputFileParts['filename']);
     /** fix formats */
     $format_bold =& $workbook->addFormat();
     $format_bold->setBold();
     $timeexec['wrkbkOk'] = microtime(TRUE);
     /** info rows */
     $row = -1;
     $worksheet->writeString(++$row, 0, 'kigkonsult.se', $format_bold);
     $worksheet->writeString($row, 1, ICALCREATOR_VERSION, $format_bold);
     $worksheet->writeString($row, 2, ICALCNVVERSION . ' iCal2xls', $format_bold);
     $worksheet->writeString($row, 3, date('Y-m-d H:i:s'));
     $filename = $remoteInput ? $inputdirFile : $inputFileParts['basename'];
     $worksheet->writeString(++$row, 0, 'iCal input', $format_bold);
     $worksheet->writeString($row, 1, $filename);
     $worksheet->writeString($row, 2, 'xls output', $format_bold);
     $worksheet->writeString($row, 3, $outputFileParts['basename']);
     if (FALSE !== ($prop = $calendar->getProperty('CALSCALE'))) {
         $worksheet->writeString(++$row, 0, 'CALSCALE', $format_bold);
         $worksheet->writeString($row, 1, $prop);
     }
     if (FALSE !== ($prop = $calendar->getProperty('METHOD'))) {
         $worksheet->writeString(++$row, 0, 'METHOD', $format_bold);
         $worksheet->writeString($row, 1, $prop);
     }
     while (FALSE !== ($xprop = $calendar->getProperty())) {
         $worksheet->writeString(++$row, 0, $xprop[0], $format_bold);
         $worksheet->writeString($row, 1, $xprop[1]);
     }
     $timeexec['infoOk'] = microtime(TRUE);
     if (FALSE === ($propsToSkip = $this->getConfig('skip'))) {
         $propsToSkip = array();
     }
     /** fix property order list */
     $proporderOrg = array();
     for ($key = 2; $key < 99; $key++) {
         if (FALSE !== ($value = $this->getConfig($key))) {
             $proporderOrg[$value] = $key;
             if ($this->log) {
                 $this->log->log("{$value} in column {$key}", 7);
             }
         }
     }
     /** fix vtimezone property order list */
     $proporder = $proporderOrg;
     $proporder['TYPE'] = 0;
     $proporder['ORDER'] = 1;
     $props = array('TZID', 'LAST-MODIFIED', 'TZURL', 'DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RRULE', 'RDATE', 'TZNAME');
     $pix = 2;
     foreach ($props as $prop) {
         if (isset($proporder[$prop])) {
             continue;
         }
         if (in_array($prop, $propsToSkip)) {
             if ($this->log) {
                 $this->log->log("'{$prop}' removed from output", 7);
             }
             continue;
         }
         while (in_array($pix, $proporder)) {
             $pix++;
         }
         $proporder[$prop] = $pix++;
     }
     /** remove unused properties from and add x-props to property order list */
     $maxpropix = 11;
     if ($maxpropix != count($proporder) - 1) {
         $maxpropix = count($proporder) - 1;
     }
     $compsinfo = $calendar->getConfig('compsinfo');
     $potmp = array();
     $potmp[0] = 'TYPE';
     $potmp[1] = 'ORDER';
     foreach ($compsinfo as $cix => $compinfo) {
         if ('vtimezone' != $compinfo['type']) {
             continue;
         }
         $comp = $calendar->getComponent($compinfo['ordno']);
         foreach ($compinfo['props'] as $propName => $propcnt) {
             if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                 $potmp[$proporder[$propName]] = $propName;
             } elseif ('X-PROP' == $propName) {
                 while ($xprop = $comp->getProperty()) {
                     if (!in_array($xprop[0], $potmp)) {
                         $maxpropix += 1;
                         $potmp[$maxpropix] = $xprop[0];
                     }
                     // end if
                 }
                 // end while xprop
             }
             // end X-PROP
         }
         // end $compinfo['props']
         if (isset($compinfo['sub'])) {
             foreach ($compinfo['sub'] as $compinfo2) {
                 foreach ($compinfo2['props'] as $propName => $propcnt) {
                     if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                         $potmp[$proporder[$propName]] = $propName;
                     } elseif ('X-PROP' == $propName) {
                         $scomp = $comp->getComponent($compinfo2['ordno']);
                         while ($xprop = $scomp->getProperty()) {
                             if (!in_array($xprop[0], $potmp)) {
                                 $maxpropix += 1;
                                 $potmp[$maxpropix] = $xprop[0];
                             }
                             // end if
                         }
                         // end while xprop
                     }
                     // end X-PROP
                 }
                 // end $compinfo['sub']['props']
             }
             // end foreach( $compinfo['sub']
         }
         // end if( isset( $compinfo['sub']
     }
     // end foreach compinfo - vtimezone
     ksort($potmp, SORT_NUMERIC);
     $proporder = array_flip(array_values($potmp));
     if ($this->log) {
         $this->log->log("timezone proporder=" . implode(',', array_flip($proporder)), 7);
     }
     /** create vtimezone info */
     if (2 < count($proporder)) {
         $row += 1;
         /** create vtimezone header row */
         foreach ($proporder as $propName => $col) {
             if (isset($this->config[$propName])) {
                 $worksheet->writeString($row, $col, $this->config[$propName], $format_bold);
                 // check map of userfriendly name to iCal property name
                 if ($this->log) {
                     $this->log->log("header row, col={$col}: {$propName}, replaced by " . $this->config[$propName], 7);
                 }
             } else {
                 $worksheet->writeString($row, $col, $propName, $format_bold);
             }
         }
         $allowedProps = array('VTIMEZONE' => array('TZID', 'LAST-MODIFIED', 'TZURL'), 'STANDARD' => array('DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RDATE', 'RRULE', 'TZNAME'), 'DAYLIGHT' => array('DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RDATE', 'RRULE', 'TZNAME'));
         /** create vtimezone data rows */
         foreach ($compsinfo as $cix => $compinfo) {
             if ('vtimezone' != $compinfo['type']) {
                 continue;
             }
             $row += 1;
             $worksheet->writeString($row, $proporder['TYPE'], $compinfo['type']);
             $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno']);
             $comp = $calendar->getComponent($compinfo['ordno']);
             foreach ($proporder as $propName => $col) {
                 if ('TYPE' == $propName || 'ORDER' == $propName) {
                     continue;
                 }
                 if ('X-' == substr($propName, 0, 2)) {
                     continue;
                 }
                 if (!in_array($propName, $allowedProps['VTIMEZONE'])) {
                     // check if component allows property
                     if ($this->log) {
                         $this->log->log("ERROR 7, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo['type'] . "': '{$propName}'", PEAR_LOG_INFO);
                     }
                     continue;
                 }
                 if (isset($compinfo['props'][$propName])) {
                     if ('LAST-MODIFIED' == $propName) {
                         $fcn = 'createLastModified';
                     } else {
                         $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1));
                     }
                     if (!method_exists($comp, $fcn)) {
                         if ($this->log) {
                             $this->log->log('ERROR 8 INPUT FILE:"' . $filename . '" iCalcreator: unknown property: "' . $propName . '" (' . $fcn . ')', PEAR_LOG_INFO);
                         }
                         continue;
                     }
                     $output = str_replace("{$calnl} ", '', rtrim($comp->{$fcn}()));
                     $output = str_replace($propName . ';', '', $output);
                     $output = str_replace($propName . ':', '', $output);
                     $worksheet->writeString($row, $proporder[$propName], fixiCalString($output));
                 }
             }
             // end foreach( $proporder
             if (isset($compinfo['props']['X-PROP'])) {
                 while ($xprop = $comp->getProperty()) {
                     $output = str_replace("{$calnl} ", '', rtrim($xprop[1]));
                     $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output));
                 }
             }
             if (isset($compinfo['sub'])) {
                 foreach ($compinfo['sub'] as $compinfo2) {
                     $row += 1;
                     $worksheet->writeString($row, $proporder['TYPE'], $compinfo2['type']);
                     $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno'] . ':' . $compinfo2['ordno']);
                     $scomp = $comp->getComponent($compinfo2['ordno']);
                     foreach ($proporder as $propName => $col) {
                         if ('TYPE' == $propName || 'ORDER' == $propName) {
                             continue;
                         }
                         if ('X-' == substr($propName, 0, 2)) {
                             continue;
                         }
                         if (!in_array($propName, $allowedProps[strtoupper($compinfo2['type'])])) {
                             // check if component allows property
                             if ($this->log) {
                                 $this->log->log("ERROR 9, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo2['type'] . "': '{$propName}'", PEAR_LOG_INFO);
                             }
                             continue;
                         }
                         if (isset($compinfo2['props'][$propName])) {
                             $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1));
                             if (!method_exists($scomp, $fcn)) {
                                 if ($this->log) {
                                     $this->log->log('ERROR 10 INPUT FILE:"' . $filename . '" iCalcreator: unknown property: "' . $propName . '" (' . $fcn . ')', PEAR_LOG_INFO);
                                 }
                                 continue;
                             }
                             $output = str_replace("{$calnl} ", '', rtrim($scomp->{$fcn}()));
                             $output = str_replace($propName . ';', '', $output);
                             $output = str_replace($propName . ':', '', $output);
                             $worksheet->writeString($row, $proporder[$propName], fixiCalString($output));
                         }
                     }
                     // end foreach( $proporder
                     if (isset($compinfo2['props']['X-PROP'])) {
                         while ($xprop = $scomp->getProperty()) {
                             $output = str_replace("{$calnl} ", '', rtrim($xprop[1]));
                             $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output));
                         }
                     }
                 }
                 // end foreach( $compinfo['sub']
             }
             // end if( isset( $compinfo['sub']['props'] ))
         }
         // end foreach
     }
     // end vtimezone
     $timeexec['zoneOk'] = microtime(TRUE);
     $maxColCount = count($proporder);
     /** fix property order list */
     $proporder = $proporderOrg;
     $proporder['TYPE'] = 0;
     $proporder['ORDER'] = 1;
     $props = array('UID', 'DTSTAMP', 'SUMMARY', 'DTSTART', 'DURATION', 'DTEND', 'DUE', 'RRULE', 'RDATE', 'EXRULE', 'EXDATE', 'DESCRIPTION', 'CATEGORIES', 'ORGANIZER', 'LOCATION', 'RESOURCES', 'CONTACT', 'URL', 'COMMENT', 'PRIORITY', 'ATTENDEE', 'CLASS', 'TRANSP', 'SEQUENCE', 'STATUS', 'COMPLETED', 'CREATED', 'LAST-MODIFIED', 'ACTION', 'TRIGGER', 'REPEAT', 'ATTACH', 'FREEBUSY', 'RELATED-TO', 'REQUEST-STATUS', 'GEO', 'PERCENT-COMPLETE', 'RECURRENCE-ID');
     $pix = 2;
     foreach ($props as $prop) {
         if (isset($proporder[$prop])) {
             continue;
         }
         if (in_array($prop, $propsToSkip)) {
             if ($this->log) {
                 $this->log->log("'{$prop}' removed from output", 7);
             }
             continue;
         }
         while (in_array($pix, $proporder)) {
             $pix++;
         }
         $proporder[$prop] = $pix++;
     }
     /** remove unused properties from and add x-props to property order list */
     if ($maxpropix < count($proporder) - 1) {
         $maxpropix = count($proporder) - 1;
     }
     $potmp = array();
     $potmp[0] = 'TYPE';
     $potmp[1] = 'ORDER';
     //  $potmp[2]                   =  'UID';
     foreach ($compsinfo as $cix => $compinfo) {
         if ('vtimezone' == $compinfo['type']) {
             continue;
         }
         foreach ($compinfo['props'] as $propName => $propcnt) {
             if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                 $potmp[$proporder[$propName]] = $propName;
             } elseif ('X-PROP' == $propName) {
                 $comp = $calendar->getComponent($compinfo['ordno']);
                 while ($xprop = $comp->getProperty()) {
                     if (!in_array($xprop[0], $potmp)) {
                         $maxpropix += 1;
                         $potmp[$maxpropix] = $xprop[0];
                     }
                     // end if
                 }
                 // while( $xprop
             }
             // end elseif( 'X-PROP'
         }
         // end foreach( $compinfo['props']
         if (isset($compinfo['sub'])) {
             foreach ($compinfo['sub'] as $compinfo2) {
                 foreach ($compinfo2['props'] as $propName => $propcnt) {
                     if (!in_array($propName, $potmp) && isset($proporder[$propName])) {
                         $potmp[$proporder[$propName]] = $propName;
                     } elseif ('X-PROP' == $propName) {
                         $scomp = $comp->getComponent($compinfo2['ordno']);
                         while ($xprop = $scomp->getProperty()) {
                             if (!in_array($xprop[0], $potmp)) {
                                 $maxpropix += 1;
                                 $potmp[$maxpropix] = $xprop[0];
                             }
                             // end if
                         }
                         // end while xprop
                     }
                     // end X-PROP
                 }
                 // end $compinfo['sub']['props']
             }
             // end foreach( $compinfo['sub']
         }
         // end if( isset( $compinfo['sub']
     }
     ksort($potmp, SORT_NUMERIC);
     $proporder = array_flip(array_values($potmp));
     if ($this->log) {
         $this->log->log("comp proporder=" . implode(',', array_flip($proporder)), 7);
     }
     if ($maxColCount < count($proporder)) {
         $maxColCount = count($proporder);
     }
     /** create header row */
     $row += 1;
     foreach ($proporder as $propName => $col) {
         if (isset($this->config[$propName])) {
             $worksheet->writeString($row, $col, $this->config[$propName], $format_bold);
             // check map of userfriendly name to iCal property name
             if ($this->log) {
                 $this->log->log("header row, col={$col}: {$propName}, replaced by " . $this->config[$propName], 7);
             }
         } else {
             $worksheet->writeString($row, $col, $propName, $format_bold);
         }
     }
     $allowedProps = array('VEVENT' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTEND', 'DTSTAMP', 'DTSTART', 'DURATION', 'EXDATE', 'RXRULE', 'GEO', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PRIORITY', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'TRANSP', 'UID', 'URL'), 'VTODO' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'COMPLETED', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTSTAMP', 'DTSTART', 'DUE', 'DURATION', 'EXDATE', 'EXRULE', 'GEO', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PERCENT', 'PRIORITY', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'UID', 'URL'), 'VJOURNAL' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTSTAMP', 'DTSTART', 'EXDATE', 'EXRULE', 'LAST-MODIFIED', 'ORGANIZER', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'UID', 'URL'), 'VFREEBUSY' => array('ATTENDEE', 'COMMENT', 'CONTACT', 'DTEND', 'DTSTAMP', 'DTSTART', 'DURATION', 'FREEBUSY', 'ORGANIZER', 'UID', 'URL'), 'VALARM' => array('ACTION', 'ATTACH', 'ATTENDEE', 'DESCRIPTION', 'DURATION', 'REPEAT', 'SUMMARY', 'TRIGGER'));
     /** create data rows */
     foreach ($compsinfo as $cix => $compinfo) {
         if ('vtimezone' == $compinfo['type']) {
             continue;
         }
         $row += 1;
         $worksheet->writeString($row, $proporder['TYPE'], $compinfo['type']);
         $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno']);
         //    $worksheet->write(         $row, $proporder['UID'],   $compinfo['uid'] );
         $comp = $calendar->getComponent($compinfo['ordno']);
         foreach ($proporder as $propName => $col) {
             if ('TYPE' == $propName || 'ORDER' == $propName) {
                 continue;
             }
             if ('X-' == substr($propName, 0, 2)) {
                 continue;
             }
             if (!in_array($propName, $allowedProps[strtoupper($compinfo['type'])])) {
                 // check if component allows property
                 if ($this->log) {
                     $this->log->log("ERROR 11, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo['type'] . "': '{$propName}'", PEAR_LOG_INFO);
                 }
                 continue;
             }
             if (isset($compinfo['props'][$propName])) {
                 switch ($propName) {
                     case 'LAST-MODIFIED':
                         $fcn = 'createLastModified';
                         break;
                     case 'RECURRENCE-ID':
                         $fcn = 'createRecurrenceid';
                         break;
                     case 'RELATED-TO':
                         $fcn = 'createRelatedTo';
                         break;
                     case 'REQUEST-STATUS':
                         $fcn = 'createRequestStatus';
                         break;
                     case 'PERCENT-COMPLETE':
                         $fcn = 'createPercentComplete';
                         break;
                     default:
                         $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1));
                 }
                 if (!method_exists($comp, $fcn)) {
                     if ($this->log) {
                         $this->log->log("ERROR 12 INPUT FILE:'{$filename}' iCalcreator: unknown property: '{$propName}' ({$fcn})", PEAR_LOG_INFO);
                     }
                     continue;
                 }
                 $output = str_replace("{$calnl} ", '', rtrim($comp->{$fcn}()));
                 $output = str_replace($propName . ';', '', $output);
                 $output = str_replace($propName . ':', '', $output);
                 $worksheet->writeString($row, $proporder[$propName], fixiCalString($output));
             }
         }
         // end foreach( $proporder
         if (isset($compinfo['props']['X-PROP'])) {
             while ($xprop = $comp->getProperty()) {
                 $output = str_replace("{$calnl} ", '', rtrim($xprop[1]));
                 $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output));
             }
         }
         if (isset($compinfo['sub'])) {
             foreach ($compinfo['sub'] as $compinfo2) {
                 $row += 1;
                 $worksheet->writeString($row, $proporder['TYPE'], $compinfo2['type']);
                 $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno'] . ':' . $compinfo2['ordno']);
                 $scomp = $comp->getComponent($compinfo2['ordno']);
                 foreach ($proporder as $propName => $col) {
                     if ('TYPE' == $propName || 'ORDER' == $propName) {
                         continue;
                     }
                     if ('X-' == substr($propName, 0, 2)) {
                         continue;
                     }
                     if (!in_array($propName, $allowedProps[strtoupper($compinfo2['type'])])) {
                         // check if component allows property
                         if ($this->log) {
                             $this->log->log("ERROR 13, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo2['type'] . "': '{$propName}'", PEAR_LOG_INFO);
                         }
                         continue;
                     }
                     if (isset($compinfo2['props'][$propName])) {
                         $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1));
                         if (!method_exists($scomp, $fcn)) {
                             if ($this->log) {
                                 $this->log->log("ERROR 14 INPUT FILE:'{$filename}' iCalcreator: unknown property: '{$propName}' ({$fcn})", PEAR_LOG_INFO);
                             }
                             continue;
                         }
                         $output = str_replace("{$calnl} ", '', rtrim($scomp->{$fcn}()));
                         $output = str_replace($propName . ';', '', $output);
                         $output = str_replace($propName . ':', '', $output);
                         $worksheet->writeString($row, $proporder[$propName], fixiCalString($output));
                     }
                     // end if( isset( $compinfo2['props'][$propName]
                 }
                 // end foreach( $proporder
                 if (isset($compinfo2['props']['X-PROP'])) {
                     while ($xprop = $scomp->getProperty()) {
                         $output = str_replace("{$calnl} ", '', rtrim($xprop[1]));
                         $output = str_replace('\\n ', chr(10), $output);
                         $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output));
                     }
                 }
                 // end if( isset( $compinfo2['props']['X-PROP']
             }
             // end foreach( $compinfo['sub']
         }
         // end if( isset( $compinfo['sub']
     }
     // foreach( $compsinfo as
     if ($this->log) {
         $timeexec['exit'] = microtime(TRUE);
         $msg = "'{$filename}'";
         $msg .= ' fileOk:' . number_format($timeexec['fileOk'] - $timeexec['start'], 5);
         $msg .= ' wrkbkOk:' . number_format($timeexec['wrkbkOk'] - $timeexec['fileOk'], 5);
         $msg .= ' infoOk:' . number_format($timeexec['infoOk'] - $timeexec['wrkbkOk'], 5);
         $msg .= ' zoneOk:' . number_format($timeexec['zoneOk'] - $timeexec['infoOk'], 5);
         $msg .= ' compOk:' . number_format($timeexec['exit'] - $timeexec['zoneOk'], 5);
         $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . 'sec';
         $msg .= ', ' . ($row + 1) . " rows, {$maxColCount} cols";
         $this->log->log($msg, PEAR_LOG_DEBUG);
         $msg = "'{$filename}' (" . count($compsinfo) . ' components) start:' . date('H:i:s', $timeexec['start']);
         $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . 'sec';
         if ($save) {
             $msg .= " saved as '{$outputdirFile}'";
         } else {
             $msg .= " redirected as '" . $outputFileParts['basename'] . "'";
         }
         $this->log->log($msg, PEAR_LOG_NOTICE);
     }
     /** Close and, opt., send the file */
     if ($this->log) {
         $this->log->flush();
     }
     $workbook->close();
     return TRUE;
 }
Exemple #11
0
 /**
  * Returns the latest build number from the database
  * @return mixed
  * @access private
  */
 public function latestVersion()
 {
     return $this->formatVersionNumber($this->settings->getConfig('app.database.version'));
 }
Exemple #12
0
 /**
  * Get the configuration display of the authentication driver
  * @param  object $userman The userman object
  * @param  object $freepbx The FreePBX BMO object
  * @return string          html display data
  */
 public static function getConfig($userman, $freepbx)
 {
     $config = $userman->getConfig("authMSADSettings");
     $status = array("connected" => false, "type" => "info", "message" => _("Not Connected"));
     if (!empty($config['host']) && !empty($config['username']) && !empty($config['password']) && !empty($config['domain'])) {
         $msad = new static($userman, $freepbx);
         try {
             $msad->connect();
             $status = array("connected" => true, "type" => "success", "message" => _("Connected"));
         } catch (\Exception $e) {
             $status = array("connected" => false, "type" => "danger", "message" => $e->getMessage());
         }
     } elseif (!empty($config['host']) || !empty($config['username']) || !empty($config['password']) || !empty($config['domain'])) {
         $status = array("connected" => false, "type" => "warning", "message" => _("Not all of the connection parameters have been filled out"));
     }
     return load_view(dirname(dirname(dirname(__DIR__))) . "/views/msad.php", array("config" => $config, "status" => $status));
 }
Exemple #13
0
 /**
  * add calendar component as subcomponent to container for subcomponents
  *
  * @author Kjell-Inge Gustafsson <*****@*****.**>
  * @since 1.x.x - 2007-04-24
  * @param object $component calendar component
  * @param mixed $arg1 optional, ordno/component type/ component uid
  * @param mixed $arg2 optional, ordno if arg1 = component type
  * @return void
  */
 function setComponent($component, $arg1 = FALSE, $arg2 = FALSE)
 {
     if ('' >= $component->getConfig('language')) {
         $component->setConfig('language', $this->getConfig('language'));
     }
     $component->setConfig('nl', $this->getConfig('nl'));
     $component->setConfig('unique_id', $this->getConfig('unique_id'));
     $component->setConfig('format', $this->getConfig('format'));
     if (!in_array($component->objName, array('valarm', 'vtimezone'))) {
         unset($component->propix);
         /* make sure dtstamp and uid is set */
         $dummy = $component->getProperty('dtstamp');
         $dummy = $component->getProperty('uid');
     }
     if (!$arg1) {
         $this->subcomponents[] = $component;
         return TRUE;
     }
     $argType = $index = null;
     if (is_int($arg1)) {
         $argType = 'INDEX';
         $index = --$arg1;
     } elseif (strlen($arg1) <= strlen('vfreebusy') && FALSE === strpos($arg1, '@')) {
         $argType = strtolower($arg1);
         $index = is_int($arg2) ? --$arg2 : 0;
     }
     $cix2sC = 0;
     foreach ($this->subcomponents as $cix => $subcomponent) {
         unset($subcomponent->propix);
         if ('INDEX' == $argType && $index == $cix) {
             $this->subcomponents[$cix] = $component;
             return TRUE;
         } elseif ($argType == $subcomponent->objName) {
             if ($index == $cix2sC) {
                 $this->subcomponents[$cix] = $component;
                 return TRUE;
             }
             $cix2sC++;
         } elseif (!$argType && $arg1 == $subcomponent2->getProperty('uid')) {
             $this->subcomponents[$cix] = $component;
             return TRUE;
         }
     }
     /* not found.. . insert anyway.. .*/
     $this->subcomponents[] = $component;
 }
 /**
  * @param object $abc
  */
 public function __construct($abc)
 {
     $this->abc = $abc;
     $this->contentEnable = $abc->getConfig('content_enable');
 }
Exemple #15
0
 /**
  * Throw 500 error exception
  * @param \Exception $e
  * @throws ServerErrorHttpException
  */
 private function _throwServerError(\Exception $e)
 {
     $uri = (string) $this->httpClient->getConfig('base_uri');
     throw new ServerErrorHttpException(get_class($e) . ': url=' . $uri . ' ' . $e->getMessage(), 500);
 }
Exemple #16
0
/**
 * format iCal XML output, rfc6321, using PHP SimpleXMLElement
 *
 * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
 * @since 2.18.1 - 2013-08-18
 * @param object $calendar   iCalcreator vcalendar instance reference
 * @uses ICALCREATOR_VERSION
 * @uses vcalendar::getProperty()
 * @uses _addXMLchild()
 * @uses vcalendar::getConfig()
 * @uses vcalendar::getComponent()
 * @uses calendarComponent::$objName
 * @uses calendarComponent::getProperty()
 * @return string
 */
function iCal2XML($calendar)
{
    /** fix an SimpleXMLElement instance and create root element */
    $xmlstr = '<?xml version="1.0" encoding="utf-8"?><icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0">';
    $xmlstr .= '<!-- created ' . gmdate('Ymd\\THis\\Z');
    $xmlstr .= ' using kigkonsult.se ' . ICALCREATOR_VERSION . ' iCal2XMl (rfc6321) -->';
    $xmlstr .= '</icalendar>';
    $xml = new SimpleXMLElement($xmlstr);
    $vcalendar = $xml->addChild('vcalendar');
    /** fix calendar properties */
    $properties = $vcalendar->addChild('properties');
    $calProps = array('version', 'prodid', 'calscale', 'method');
    foreach ($calProps as $calProp) {
        if (FALSE !== ($content = $calendar->getProperty($calProp))) {
            _addXMLchild($properties, $calProp, 'text', $content);
        }
    }
    while (FALSE !== ($content = $calendar->getProperty(FALSE, FALSE, TRUE))) {
        _addXMLchild($properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params']);
    }
    $langCal = $calendar->getConfig('language');
    /** prepare to fix components with properties */
    $components = $vcalendar->addChild('components');
    /** fix component properties */
    while (FALSE !== ($component = $calendar->getComponent())) {
        $compName = $component->objName;
        $child = $components->addChild($compName);
        $properties = $child->addChild('properties');
        $langComp = $component->getConfig('language');
        $props = $component->getConfig('setPropertyNames');
        foreach ($props as $prop) {
            switch (strtolower($prop)) {
                case 'attach':
                    // may occur multiple times, below
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        $type = isset($content['params']['VALUE']) && 'BINARY' == $content['params']['VALUE'] ? 'binary' : 'uri';
                        unset($content['params']['VALUE']);
                        _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                    }
                    break;
                case 'attendee':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if (isset($content['params']['CN']) && !isset($content['params']['LANGUAGE'])) {
                            if ($langComp) {
                                $content['params']['LANGUAGE'] = $langComp;
                            } elseif ($langCal) {
                                $content['params']['LANGUAGE'] = $langCal;
                            }
                        }
                        _addXMLchild($properties, $prop, 'cal-address', $content['value'], $content['params']);
                    }
                    break;
                case 'exdate':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        $type = isset($content['params']['VALUE']) && 'DATE' == $content['params']['VALUE'] ? 'date' : 'date-time';
                        unset($content['params']['VALUE']);
                        _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                    }
                    break;
                case 'freebusy':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if (is_array($content) && isset($content['value']['fbtype'])) {
                            $content['params']['FBTYPE'] = $content['value']['fbtype'];
                            unset($content['value']['fbtype']);
                        }
                        _addXMLchild($properties, $prop, 'period', $content['value'], $content['params']);
                    }
                    break;
                case 'request-status':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if (!isset($content['params']['LANGUAGE'])) {
                            if ($langComp) {
                                $content['params']['LANGUAGE'] = $langComp;
                            } elseif ($langCal) {
                                $content['params']['LANGUAGE'] = $langCal;
                            }
                        }
                        _addXMLchild($properties, $prop, 'rstatus', $content['value'], $content['params']);
                    }
                    break;
                case 'rdate':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        $type = 'date-time';
                        if (isset($content['params']['VALUE'])) {
                            if ('DATE' == $content['params']['VALUE']) {
                                $type = 'date';
                            } elseif ('PERIOD' == $content['params']['VALUE']) {
                                $type = 'period';
                            }
                        }
                        unset($content['params']['VALUE']);
                        _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                    }
                    break;
                case 'categories':
                case 'comment':
                case 'contact':
                case 'description':
                case 'related-to':
                case 'resources':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if ('related-to' != $prop && !isset($content['params']['LANGUAGE'])) {
                            if ($langComp) {
                                $content['params']['LANGUAGE'] = $langComp;
                            } elseif ($langCal) {
                                $content['params']['LANGUAGE'] = $langCal;
                            }
                        }
                        _addXMLchild($properties, $prop, 'text', $content['value'], $content['params']);
                    }
                    break;
                case 'x-prop':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params']);
                    }
                    break;
                case 'created':
                    // single occurence below, if set
                // single occurence below, if set
                case 'completed':
                case 'dtstamp':
                case 'last-modified':
                    $utcDate = TRUE;
                case 'dtstart':
                case 'dtend':
                case 'due':
                case 'recurrence-id':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        $type = isset($content['params']['VALUE']) && 'DATE' == $content['params']['VALUE'] ? 'date' : 'date-time';
                        unset($content['params']['VALUE']);
                        if (isset($content['params']['TZID']) && empty($content['params']['TZID']) || @is_null($content['params']['TZID'])) {
                            unset($content['params']['TZID']);
                        }
                        _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                    }
                    unset($utcDate);
                    break;
                case 'duration':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $prop, 'duration', $content['value'], $content['params']);
                    }
                    break;
                case 'exrule':
                case 'rrule':
                    while (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $prop, 'recur', $content['value'], $content['params']);
                    }
                    break;
                case 'class':
                case 'location':
                case 'status':
                case 'summary':
                case 'transp':
                case 'tzid':
                case 'uid':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if (('location' == $prop || 'summary' == $prop) && !isset($content['params']['LANGUAGE'])) {
                            if ($langComp) {
                                $content['params']['LANGUAGE'] = $langComp;
                            } elseif ($langCal) {
                                $content['params']['LANGUAGE'] = $langCal;
                            }
                        }
                        _addXMLchild($properties, $prop, 'text', $content['value'], $content['params']);
                    }
                    break;
                case 'geo':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $prop, 'geo', $content['value'], $content['params']);
                    }
                    break;
                case 'organizer':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        if (isset($content['params']['CN']) && !isset($content['params']['LANGUAGE'])) {
                            if ($langComp) {
                                $content['params']['LANGUAGE'] = $langComp;
                            } elseif ($langCal) {
                                $content['params']['LANGUAGE'] = $langCal;
                            }
                        }
                        _addXMLchild($properties, $prop, 'cal-address', $content['value'], $content['params']);
                    }
                    break;
                case 'percent-complete':
                case 'priority':
                case 'sequence':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $prop, 'integer', $content['value'], $content['params']);
                    }
                    break;
                case 'tzurl':
                case 'url':
                    if (FALSE !== ($content = $component->getProperty($prop, FALSE, TRUE))) {
                        _addXMLchild($properties, $prop, 'uri', $content['value'], $content['params']);
                    }
                    break;
            }
            // end switch( $prop )
        }
        // end foreach( $props as $prop )
        /** fix subComponent properties, if any */
        while (FALSE !== ($subcomp = $component->getComponent())) {
            $subCompName = $subcomp->objName;
            $child2 = $child->addChild($subCompName);
            $properties = $child2->addChild('properties');
            $langComp = $subcomp->getConfig('language');
            $subCompProps = $subcomp->getConfig('setPropertyNames');
            foreach ($subCompProps as $prop) {
                switch (strtolower($prop)) {
                    case 'attach':
                        // may occur multiple times, below
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            $type = isset($content['params']['VALUE']) && 'BINARY' == $content['params']['VALUE'] ? 'binary' : 'uri';
                            unset($content['params']['VALUE']);
                            _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                        }
                        break;
                    case 'attendee':
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            if (isset($content['params']['CN']) && !isset($content['params']['LANGUAGE'])) {
                                if ($langComp) {
                                    $content['params']['LANGUAGE'] = $langComp;
                                } elseif ($langCal) {
                                    $content['params']['LANGUAGE'] = $langCal;
                                }
                            }
                            _addXMLchild($properties, $prop, 'cal-address', $content['value'], $content['params']);
                        }
                        break;
                    case 'comment':
                    case 'tzname':
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            if (!isset($content['params']['LANGUAGE'])) {
                                if ($langComp) {
                                    $content['params']['LANGUAGE'] = $langComp;
                                } elseif ($langCal) {
                                    $content['params']['LANGUAGE'] = $langCal;
                                }
                            }
                            _addXMLchild($properties, $prop, 'text', $content['value'], $content['params']);
                        }
                        break;
                    case 'rdate':
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            $type = 'date-time';
                            if (isset($content['params']['VALUE'])) {
                                if ('DATE' == $content['params']['VALUE']) {
                                    $type = 'date';
                                } elseif ('PERIOD' == $content['params']['VALUE']) {
                                    $type = 'period';
                                }
                            }
                            unset($content['params']['VALUE']);
                            _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                        }
                        break;
                    case 'x-prop':
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            _addXMLchild($properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params']);
                        }
                        break;
                    case 'action':
                        // single occurence below, if set
                    // single occurence below, if set
                    case 'description':
                    case 'summary':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            if ('action' != $prop && !isset($content['params']['LANGUAGE'])) {
                                if ($langComp) {
                                    $content['params']['LANGUAGE'] = $langComp;
                                } elseif ($langCal) {
                                    $content['params']['LANGUAGE'] = $langCal;
                                }
                            }
                            _addXMLchild($properties, $prop, 'text', $content['value'], $content['params']);
                        }
                        break;
                    case 'dtstart':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            unset($content['value']['tz'], $content['params']['VALUE']);
                            // always local time
                            _addXMLchild($properties, $prop, 'date-time', $content['value'], $content['params']);
                        }
                        break;
                    case 'duration':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            _addXMLchild($properties, $prop, 'duration', $content['value'], $content['params']);
                        }
                        break;
                    case 'repeat':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            _addXMLchild($properties, $prop, 'integer', $content['value'], $content['params']);
                        }
                        break;
                    case 'trigger':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            if (isset($content['value']['year']) && isset($content['value']['month']) && isset($content['value']['day'])) {
                                $type = 'date-time';
                            } else {
                                $type = 'duration';
                                if (!isset($content['value']['relatedStart']) || TRUE !== $content['value']['relatedStart']) {
                                    $content['params']['RELATED'] = 'END';
                                }
                            }
                            _addXMLchild($properties, $prop, $type, $content['value'], $content['params']);
                        }
                        break;
                    case 'tzoffsetto':
                    case 'tzoffsetfrom':
                        if (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            _addXMLchild($properties, $prop, 'utc-offset', $content['value'], $content['params']);
                        }
                        break;
                    case 'rrule':
                        while (FALSE !== ($content = $subcomp->getProperty($prop, FALSE, TRUE))) {
                            _addXMLchild($properties, $prop, 'recur', $content['value'], $content['params']);
                        }
                        break;
                }
                // switch( $prop )
            }
            // end foreach( $subCompProps as $prop )
        }
        // end while( FALSE !== ( $subcomp = $component->getComponent()))
    }
    // end while( FALSE !== ( $component = $calendar->getComponent()))
    return $xml->asXML();
}