diff options
126 files changed, 4273 insertions, 4398 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43c65f365..40e219551 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ # Select image from https://hub.docker.com/_/php/ #image: php:7.2 -# Use a prepared Hubzilla image to optimise pipeline run +# Use a prepared Hubzilla image to optimise pipeline duration image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.2 @@ -32,55 +32,28 @@ variables: before_script: +# pecl and composer do not work with PHP production restrictions (from Hubzilla Docker image) +- if [ -f /usr/local/etc/php/conf.d/z_prod.ini ]; then mv /usr/local/etc/php/conf.d/z_prod.ini /usr/local/etc/php/conf.d/z_prod.ini.off; fi # Install & enable Xdebug for code coverage reports - pecl install xdebug - docker-php-ext-enable xdebug # Install composer - curl -sS https://getcomposer.org/installer | php # Install dev libraries from composer -- php composer.phar install --no-progress +- php ./composer.phar install --no-progress -# test PHP7 with MySQL 5.7 -php7.2_mysql 1/2: +# hidden job definition with template for MySQL/MariaDB +.job_template_mysql: &job_definition_mysql stage: test - services: - - mysql:5.7 - script: - - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text - - -# test PHP7 with MySQL latest (8) -php7.2_mysql 2/2: - stage: test - services: - - name: mysql:latest - command: ["--default-authentication-plugin=mysql_native_password"] script: - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text - -# test PHP7 with MariaDB latest (10.3) -php7.2_mariadb: - stage: test - services: - - name: mariadb:latest - alias: mysql - script: - - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" - - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text - - -# test PHP7 with PostgreSQL latest -php7.2_postgres: +# hidden job definition with template for PostgreSQL +.job_template_postgres: &job_definition_postgres stage: test services: - postgres:latest @@ -95,7 +68,10 @@ php7.2_postgres: #- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "\dt;" # Run the actual tests - vendor/bin/phpunit --configuration tests/phpunit-pgsql.xml --testdox - artifacts: + +# hidden job definition with artifacts config template +.artifacts_template: + artifacts: &artifacts_template expire_in: 1 week # Gitlab should show the results, but has problems parsing PHPUnit's junit file. reports: @@ -106,7 +82,52 @@ php7.2_postgres: - tests/results/ -# Generate Doxygen API Documentation and deploy it at GitLab pages +# PHP7.2 with MySQL 5.7 +php7.2_mysql5.7: + <<: *job_definition_mysql + services: + - mysql:5.7 + + +# PHP7.2 with MySQL 8 (latest) +php7.2_mysql8: + <<: *job_definition_mysql + services: + - name: mysql:8 + command: ["--default-authentication-plugin=mysql_native_password"] + + +# PHP7.2 with MariaDB 10.2 +php7.2_mariadb10.2: + <<: *job_definition_mysql + services: + - name: mariadb:10.2 + alias: mysql + + +# PHP7.3 with MariaDB 10.3 (latest) +php7.3_mariadb10.3: + <<: *job_definition_mysql + image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3 + services: + - name: mariadb:10.3 + alias: mysql + + +# PHP7.2 with PostgreSQL latest (11) +php7.2_postgres11: + <<: *job_definition_postgres + artifacts: *artifacts_template + + +# PHP7.3 with PostgreSQL latest (11) +php7.3_postgres11: + <<: *job_definition_postgres + image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3 + artifacts: *artifacts_template + + +# Generate Doxygen API Documentation and deploy it as GitLab pages pages: stage: deploy cache: {} diff --git a/.homeinstall/README.md b/.homeinstall/README.md index d63931a84..45e1ba0e6 100644 --- a/.homeinstall/README.md +++ b/.homeinstall/README.md @@ -1,16 +1,43 @@ # Hubzilla at Home next to your Router -Run hubzilla-setup.sh for an unattended installation of hubzilla. +This readme will show you how to install and run Hubzilla or Zap at home. + +The installation is done by a script. + +What the script will do for you... + ++ install everything required by Zap/Hubzilla, basically a web server (Apache), PHP, a database (MySQL), certbot,... ++ create a database ++ run certbot to have everything for a secure connection (httpS) ++ create a script for daily maintenance + - backup to external disk (certificates, database, /var/www/) + - renew certfificate (letsencrypt) + - update of Zap/Hubzilla + - update of Debian + - restart ++ create cron jobs for + - DynDNS (selfHOST.de or freedns.afraid.org) every 5 minutes + - Master.php for Zap/Hubzilla every 10 minutes + - daily maintenance script every day at 05:30 The script is known to work without adjustments with + Hardware - - Mini-PC with Debian-9.5-amd64, or - - Rapberry 3 with Raspbian, Debian-9.5 + - Mini-PC with Debian 9 (stretch), or + - Rapberry 3 with Raspbian, Debian 9 + DynDNS - selfHOST.de - freedns.afraid.org +The script can install both [Hubzilla](https://zotlabs.org/page/hubzilla/hubzilla-project) and [Zap](https://zotlabs.com/zap/). Make sure to use the correct GIT repositories. + ++ Hubzilla + - core: git clone https://framagit.org/hubzilla/core.git html (in this readme) + - addons: util/add_addon_repo https://framagit.org/hubzilla/addons.git hzaddons (in hubzilla-setup.sh) ++ Zap + - core: git clone https://framagit.org/zot/zap.git html (in this readme) + - addons: util/add_addon_repo https://framagit.org/zot/zap-addons.git zaddons (in hubzilla-setup.sh) + ## Disclaimers - This script does work with Debian 9 only. @@ -29,7 +56,7 @@ Hardware Software + Fresh installation of Debian 9 (Stretch) -+ Router with open ports 80 and 443 for your Hub ++ Router with open ports 80 and 443 for your web server ## The basic steps (quick overview) @@ -44,10 +71,9 @@ Software - nano hubzilla-config.txt - Read the comments carefully - Enter your values: db pass, domain, values for dyn DNS - - Make sure your external drive (for backups) is mounted + - Prepare your external disk for backups - hubzilla-setup.sh as root - ... wait, wait, wait until the script is finised - - reboot + Open your domain with a browser and step throught the initial configuration of hubzilla. ## Troubleshooting @@ -66,57 +92,27 @@ In Admin settings of hubzilla or via terminal # Step-by-Step in Detail -## Preparations Hardware - -### Mini-PC - -### Recommended: USB Drive for Backups - -The installation will create a daily backup written to an external drive. - -The USB drive must be compatible with the filesystems - -- ext4 (if you do not want to encrypt the USB) -- LUKS + ext4 (if you want to encrypt the USB) - -The backup includes - -- Hubzilla DB -- Hubzilla installation /var/www/html -- Certificates for letsencrypt - ## Preparations Software -### Install Debian Linux on the Mini-PC - -Download the stable Debian at https://www.debian.org/ -(Debian 8 is no longer supported.) +## Install Debian 9 -Create bootable USB drive with Debian on it.You could use +Provided you use a Raspberry Pi 3... -- unetbootin, https://en.wikipedia.org/wiki/UNetbootin -- or simply the linux command "dd" +Download the OS Raspbian from https://www.raspberrypi.org/downloads/raspbian/ -Example for command dd... +Follow the installation instruction there. - su - - dd if=2018-10-09-raspbian-stretch.img of=/dev/mmcblk0 +## Configure your Router -Do not forget to unmount the SD card before and check if unmounted like in this example... +Your web has to be visible in the internet. - su - - umount /dev/mmcblk0* - df -h +Open the ports 80 and 443 on your router for your Debian. Make sure your web server is marked as "exposed host". +## Preparations Dynamic IP Address -Switch off your mini pc, plug in your USB drive and start the mini pc from the -stick. Install Debian. Follow the instructions of the installation. - -### Configure your Router - -Open the ports 80 and 443 on your router for your Debian +Follow the instructions in .homeinstall/hubzilla-config.txt. -## Preparations Dynamic IP Address +In short... Your Hubzilla must be reachable by a domain that you can type in your browser @@ -132,105 +128,15 @@ There are two ways to get a domain... ...for example buy at selfHOST.de -The cost are around 10,- € once and 1,50 € per month (2017). +The cost is 1,50 € per month (2019). ### Method 2: Register a free subdomain ...for example register at freedns.afraid.org -Follow the instructions in .homeinstall/hubzilla-config.txt. - - -## Install Hubzilla on your Debian - -Login to your debian -(Provided your username is "you" and the name of the mini pc is "debian". You -could take the IP address instead of "debian") - - ssh -X you@debian - -Change to root user - - su -l - -Install git - - apt-get install git - -Make the directory for apache and change diretory to it - - mkdir /var/www - cd /var/www/ - -Clone hubzilla from git ("git pull" will update it later) - - git clone https://framagit.org/hubzilla/core.git html - -Change to the install script - - cd html/.homeinstall/ - -Copy the template file - - cp hubzilla-config.txt.template hubzilla-config.txt - -Modify the file "hubzilla-config.txt". Read the instructions there carefully and enter your values. - - nano hubzilla-config.txt - -Make sure your external drive (for backups) is plugged in and can be mounted as configured in "hubzilla-config.txt". Otherwise the daily backups will not work. - -Run the script - - ./hubzilla-setup.sh - -Wait... The script should not finish with an error message. - -In a webbrowser open your domain. -Expected: A test page of hubzilla is shown. All checks there should be -successfull. Go on... -Expected: A page for the Hubzilla server configuration shows up. - -Leave db server name "127.0.0.1" and port "0" untouched. - -Enter - -- DB user name = hubzilla -- DB pass word = This is the password you entered in "hubzilla-config.txt" -- DB name = hubzilla - -Leave db type "MySQL" untouched. - -Follow the instructions in the next pages. - -Recommended: Set path to imagemagick - -- in admin settings of hubzilla or -- via terminal - - util/config system.imagick_convert_path /usr/bin/convert - -After the daily script was executed at 05:30 (am) - -- look at /var/www/html/hubzilla-daily.log -- check your backup on the external drive -- optionally view the daily log under yourdomain.org/admin/logs/ - - set the logfile to var/www/html/hubzilla-daily.log - - -## Install Hubzilla in a Virtual Machine for Test Purposes - -Modify the file "hubzilla-config.txt". - - nano hubzilla-config.txt - -There use - - le_domain=localhost - -## Note for the Rasperry +## Note on Rasperry -The script was tested with an Raspberry 3 under Raspian (Debian 9.5, 2018-10-09-raspbian-stretch.img). +The script was tested with an Raspberry 3 under Raspian, Debian 9. It is recommended to run the Raspi without graphical frontend (X-Server). Use... @@ -240,7 +146,7 @@ to boot the Rapsi to the client console. DO NOT FORGET TO CHANGE THE DEFAULT PASSWORD FOR USER PI! -If the validation of the mail address fails for the very first registered user... +On a Raspian Stretch (Debian 9) the validation of the mail address fails for the very first user. This used to happen on some *bsd distros but there was some work to fix that a year ago (2017). So if your system isn't registered in DNS or DNS isn't active do diff --git a/.homeinstall/hubzilla-config.txt.template b/.homeinstall/hubzilla-config.txt.template index e42da0e4e..f0bf6121c 100644 --- a/.homeinstall/hubzilla-config.txt.template +++ b/.homeinstall/hubzilla-config.txt.template @@ -2,8 +2,8 @@ ### MANDATORY - database password ############# # # Please give your database password +# It is better to not use blanks inside the password. # Example: db_pass=pass_word_with_no_blanks_in_it -# Example: db_pass="this password has blanks in it" db_pass= ############################################### @@ -18,9 +18,12 @@ db_pass= # Example: my.cooldomain.org # Example: cooldomain.org # -# Example: localhost (test installation without certificates for httpS) +# You might use "localhost" for a LOCAL TEST installation. +# This is usefull if you want to debug the server inside a VM. # -# Email is optional +# Example: localhost +# +# Email is optional if you use "localhost". # # le_domain= @@ -30,7 +33,7 @@ le_email= ### OPTIONAL - selfHOST - dynamic IP address ## # # 1. Register a domain at selfhost.de -# - choose offer "DOMAIN dynamisch" 1,50€/mon at 08.01.2016 +# - choose offer "DOMAIN dynamisch" 1,50€/mon at 04/2019 # 2. Get your configuration for dynamic IP update # - Log in at selfhost.de # - go to "DynDNS Accounte" diff --git a/.homeinstall/hubzilla-setup.sh b/.homeinstall/hubzilla-setup.sh index 1f3ad5db5..023ef7afc 100755..100644 --- a/.homeinstall/hubzilla-setup.sh +++ b/.homeinstall/hubzilla-setup.sh @@ -3,7 +3,10 @@ # How to use # ---------- # -# This file automates the installation of hubzilla under Debian Linux +# This file automates the installation of +# - hubzilla: https://zotlabs.org/page/hubzilla/hubzilla-project and +# - zap: https://zotlabs.com/zap/ +# under Debian Linux # # 1) Copy the file "hubzilla-config.txt.template" to "hubzilla-config.txt" # Follow the instuctions there @@ -25,16 +28,14 @@ # * php, # * mysql - the database for hubzilla, # * phpmyadmin, -# * git to download and update hubzilla itself +# * git to download and update hubzilla addon # - download hubzilla core and addons # - configure cron -# * "poller.php" for regular background prozesses of hubzilla -# * to_do "apt-get update" and "apt-get dist-upgrade" to keep linux -# up-to-date -# * to_do backup hubzillas database and files (rsnapshot) -# - configure dynamic ip with cron -# - to_do letsencrypt -# - to_do redirection to https +# * "Master.php" for regular background prozesses of hubzilla +# * "apt-get update" and "apt-get dist-upgrade" and "apt-get autoremove" to keep linux up-to-date +# * run command to keep the IP up-to-date > DynDNS provided by selfHOST.de or freedns.afraid.org +# * backup hubzillas database and files (rsync) +# - letsencrypt # # # Discussion @@ -43,26 +44,11 @@ # Security - password is the same for mysql-server, phpmyadmin and hubzilla db # - The script runs into installation errors for phpmyadmin if it uses # different passwords. For the sake of simplicity one singel password. -# -# Security - suhosin for PHP -# - The script does not install suhosin. -# - Is the security package suhosin usefull or not usefull? # # Hubzilla - email verification # - The script switches off email verification off in all htconfig.tpl. # Example: /var/www/html/view/en/htconfig.tpl # - Is this a silly idea or not? -# -# -# Remove Hubzilla (for a fresh start using the script) -# ---------------------------------------------------- -# -# You could use /var/www/hubzilla-remove.sh -# that is created by hubzilla-setup.sh. -# -# The script will remove (almost everything) what was installed by the script. -# After the removal you could run the script again to have a fresh install -# of all applications including hubzilla and its database. # # How to restore from backup # -------------------------- @@ -76,18 +62,10 @@ # # hubzilla-daily.sh makes a (daily) backup of all relevant files # - /var/lib/mysql/ > hubzilla database -# - /var/www/html/ > hubzilla from github -# - /var/www/letsencrypt/ > certificates -# -# hubzilla-daily.sh writes the backup -# - either to an external disk compatible to LUKS+ext4 (see hubzilla-config.txt) -# - or to /var/cache/rsnapshot in case the external disk is not plugged in +# - /var/www/ > hubzilla/zap from github +# - /etc/letsencrypt/ > certificates # -# Restore backup -# - - - - - - - -# -# This was not tested yet. -# Bacically you can copy the files from the backup to the server. +# hubzilla-daily.sh writes the backup to an external disk compatible to LUKS+ext4 (see hubzilla-config.txt) # # Credits # ------- @@ -136,11 +114,11 @@ function check_config { # backup is important and should be checked if [ -n "$backup_device_name" ] then - if [ ! -d "$backup_mount_point" ] - then - mkdir "$backup_mount_point" - fi - device_mounted=0 + if [ ! -d "$backup_mount_point" ] + then + mkdir "$backup_mount_point" + fi + device_mounted=0 if fdisk -l | grep -i "$backup_device_name.*linux" then print_info "ok - filesystem of external device is linux" @@ -264,7 +242,7 @@ function install_sendmail { function install_php { # openssl and mbstring are included in libapache2-mod-php print_info "installing php..." - nocheck_install "libapache2-mod-php php php-pear php-curl php-mcrypt php-gd" + nocheck_install "libapache2-mod-php php php-pear php-curl php-mcrypt php-gd php-mysqli php-mbstring php-xml" sed -i "s/^upload_max_filesize =.*/upload_max_filesize = 100M/g" /etc/php/7.0/apache2/php.ini sed -i "s/^post_max_size =.*/post_max_size = 100M/g" /etc/php/7.0/apache2/php.ini } @@ -449,11 +427,11 @@ function configure_cron_selfhost { print_info "configure cron for selfhost..." if [ -z "$selfhost_user" ] then - print_info "freedns is not configured because freedns_key is empty in $configfile" + print_info "selfhost is not configured because selfhost_key is empty in $configfile" else # Use cron for dynamich ip update # - at reboot - # - every 30 minutes + # - every 5 minutes if [ -z "`grep 'selfhost-updater.sh' /etc/crontab`" ] then echo "@reboot root bash /etc/selfhost/selfhost-updater.sh update > /dev/null 2>&1" >> /etc/crontab @@ -471,89 +449,24 @@ function install_letsencrypt { then die "Failed to install let's encrypt: 'le_domain' is empty in $configfile" fi - # configure apache - apache_le_conf=/etc/apache2/sites-available/le-default.conf - if [ -f $apache_le_conf ] - then - print_info "$apache_le_conf exist already" - else - cat > $apache_le_conf <<END -# letsencrypt default Apache configuration -Alias /.well-known/acme-challenge /var/www/letsencrypt - -<Directory /var/www/letsencrypt> - Options FollowSymLinks - Allow from all -</Directory> -END - a2ensite le-default.conf - service apache2 restart - fi - # download the shell script - if [ -d $le_dir ] - then - print_info "letsenrypt exists already (nothing downloaded > no certificate created and registered)" - return 0 - fi - git clone https://github.com/lukas2511/dehydrated $le_dir - cd $le_dir - # create config file for letsencrypt.sh - echo "WELLKNOWN=$le_dir" > $le_dir/config.sh - if [ -n "$le_email" ] - then - echo "CONTACT_EMAIL=$le_email" >> $le_dir/config.sh - fi - # create domain file for letsencrypt.sh - # WATCH THIS: - # - It did not work wit "sub.domain.org www.sub.domain.org". - # - So just use "sub.domain.org" only! - echo "$le_domain" > $le_dir/domains.txt - # test apache config for letsencrpyt - url_http=http://$le_domain/.well-known/acme-challenge/domains.txt - wget_output=$(wget -nv --spider --max-redirect 0 $url_http) - if [ $? -ne 0 ] - then - die "Failed to load $url_http" - fi - # accept terms of service of letsencrypt - ./dehydrated --register --accept-terms - # run script dehydrated - # - ./dehydrated --cron --config $le_dir/config.sh -} - -function configure_apache_for_https { - print_info "configuring apache to use httpS ..." - # letsencrypt.sh - # - # "${BASEDIR}/certs/${domain}/privkey.pem" - # "${BASEDIR}/certs/${domain}/cert.pem" - # "${BASEDIR}/certs/${domain}/fullchain.pem" - # - SSLCertificateFile=${le_dir}/certs/${le_domain}/cert.pem - SSLCertificateKeyFile=${le_dir}/certs/${le_domain}/privkey.pem - SSLCertificateChainFile=${le_dir}/certs/${le_domain}/fullchain.pem - if [ ! -f $SSLCertificateFile ] + # check if user gave mail address + if [ -z "$le_email" ] then - print_warn "Failed to configure apache for httpS: Missing certificate file $SSLCertificateFile" - return 0 + die "Failed to install let's encrypt: 'le_domain' is empty in $configfile" fi - # make sure that the ssl mode is enabled - print_info "...configuring apache to use httpS - a2enmod ssl ..." - a2enmod ssl - # modify apach' ssl conf file - if grep -i "ServerName" $sslconf + nocheck_install "apt-transport-https" + # add backports to your sources.list + backports_list=/etc/apt/sources.list.d/backports.list + if [ -f $backports_list ] then - print_info "seems that apache was already configered to use httpS with $sslconf" + print_info "$backports_list exist already" else - sed -i "s/ServerAdmin.*$/ServerAdmin webmaster@localhost\\n ServerName ${le_domain}/" $sslconf - fi - sed -i s#/etc/ssl/certs/ssl-cert-snakeoil.pem#$SSLCertificateFile# $sslconf - sed -i s#/etc/ssl/private/ssl-cert-snakeoil.key#$SSLCertificateKeyFile# $sslconf - sed -i s#/etc/apache2/ssl.crt/server-ca.crt#$SSLCertificateChainFile# $sslconf - sed -i s/#SSLCertificateChainFile/SSLCertificateChainFile/ $sslconf - # apply changes - a2ensite default-ssl.conf + echo "deb https://deb.debian.org/debian stretch-backports main" > $backports_list + fi + apt-get -y update + DEBIAN_FRONTEND=noninteractive apt-get -q -y -t stretch-backports install certbot python-certbot-apache + print_info "run certbot ..." + certbot --apache -w /var/www/html -d $le_domain -m $le_email --agree-tos --non-interactive --redirect --hsts --uir service apache2 restart } @@ -572,7 +485,10 @@ function check_https { function install_hubzilla { print_info "installing hubzilla addons..." cd /var/www/html/ - util/add_addon_repo https://framagit.org/hubzilla/addons.git hzaddons + # if you install Hubzilla + util/add_addon_repo https://framagit.org/hubzilla/addons hzaddons + # if you install ZAP + #util/add_addon_repo https://framagit.org/zot/zap-addons.git zaddons mkdir -p "store/[data]/smarty3" chmod -R 777 store touch .htconfig.php @@ -582,7 +498,7 @@ function install_hubzilla { chown root:www-data /var/www/html/ chown root:www-data /var/www/html/.htaccess chmod 0644 /var/www/html/.htaccess - # try to switch off email registration + print_info "try to switch off email registration..." sed -i "s/verify_email.*1/verify_email'] = 0/" /var/www/html/view/*/ht* if [ -n "`grep -r 'verify_email.*1' /var/www/html/view/`" ] then @@ -591,49 +507,9 @@ function install_hubzilla { print_info "installed hubzilla" } -function rewrite_to_https { - print_info "configuring apache to redirect http to httpS ..." - htaccessfile=/var/www/html/.htaccess - if grep -i "https" $htaccessfile - then - print_info "...configuring apache to redirect http to httpS was already done in $htaccessfile" - else - sed -i "s#QSA]#QSA]\\n RewriteCond %{SERVER_PORT} !^443$\\n RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]#" $htaccessfile - fi - service apache2 restart -} - -# This will allways overwrite both config files -# - internal disk -# - external disk (LUKS + ext4) -# of rsnapshot for hubzilla -function install_rsnapshot { - print_info "installing rsnapshot..." - nocheck_install "rsnapshot" - # internal disk - cp -f /etc/rsnapshot.conf $snapshotconfig - sed -i "s/^cmd_cp/#cmd_cp/" $snapshotconfig - sed -i "s/^backup/#backup/" $snapshotconfig - echo "backup /var/lib/mysql/ localhost/" >> $snapshotconfig - echo "backup /var/www/html/ localhost/" >> $snapshotconfig - echo "backup /var/www/letsencrypt/ localhost/" >> $snapshotconfig - # external disk - if [ -n "$backup_device_name" ] - then - cp -f /etc/rsnapshot.conf $snapshotconfig_external_device - sed -i "s#snapshot_root.*#snapshot_root $backup_mount_point#" $snapshotconfig_external_device - sed -i "/alpha/s/6/30/" $snapshotconfig_external_device - sed -i "s/^cmd_cp/#cmd_cp/" $snapshotconfig_external_device - sed -i "s/^backup/#backup/" $snapshotconfig_external_device - if [ -z "`grep 'letsencrypt' $snapshotconfig_external_device`" ] - then - echo "backup /var/lib/mysql/ localhost/" >> $snapshotconfig_external_device - echo "backup /var/www/html/ localhost/" >> $snapshotconfig_external_device - echo "backup /var/www/letsencrypt/ localhost/" >> $snapshotconfig_external_device - fi - else - print_info "No backup configuration (rsnapshot) for external device configured. Reason: backup_device_name and/or backup_device_pass not given in $configfile" - fi +function install_rsync { + print_info "installing rsync..." + nocheck_install "rsync" } function install_cryptosetup { @@ -644,28 +520,28 @@ function install_cryptosetup { function configure_cron_daily { print_info "configuring cron..." # every 10 min for poller.php - if [ -z "`grep 'poller.php' /etc/crontab`" ] + if [ -z "`grep 'Master.php' /etc/crontab`" ] then echo "*/10 * * * * www-data cd /var/www/html; php Zotlabs/Daemon/Master.php Cron >> /dev/null 2>&1" >> /etc/crontab fi # Run external script daily at 05:30 # - stop apache and mysql-server - # - backup hubzilla + # - renew the certificate of letsencrypt + # - backup db, files (/var/www/html), certificates if letsencrypt # - update hubzilla core and addon # - update and upgrade linux - # - reboot + # - reboot is done by "shutdown -h now" because "reboot" hangs sometimes depending on the system echo "#!/bin/sh" > /var/www/$hubzilladaily echo "#" >> /var/www/$hubzilladaily echo "echo \" \"" >> /var/www/$hubzilladaily echo "echo \"+++ \$(date) +++\"" >> /var/www/$hubzilladaily echo "echo \" \"" >> /var/www/$hubzilladaily echo "echo \"\$(date) - renew certificate...\"" >> /var/www/$hubzilladaily -echo "bash $le_dir/dehydrated --cron --config $le_dir/config.sh" >> /var/www/$hubzilladaily +echo "certbot renew --noninteractive" >> /var/www/$hubzilladaily echo "#" >> /var/www/$hubzilladaily -echo "# stop hubzilla" >> /var/www/$hubzilladaily -echo "echo \"\$(date) - stoping apache and mysql...\"" >> /var/www/$hubzilladaily +echo "echo \"\$(date) - stopping apache and mysql...\"" >> /var/www/$hubzilladaily echo "service apache2 stop" >> /var/www/$hubzilladaily -echo "/etc/init.d/mysql stop # to avoid inconsistancies" >> /var/www/$hubzilladaily +echo "/etc/init.d/mysql stop # to avoid inconsistencies" >> /var/www/$hubzilladaily echo "#" >> /var/www/$hubzilladaily echo "# backup" >> /var/www/$hubzilladaily echo "echo \"\$(date) - try to mount external device for backup...\"" >> /var/www/$hubzilladaily @@ -696,11 +572,13 @@ echo " if mount $backup_device_name $backup_mount_point" >> /var/www/$hub echo " then" >> /var/www/$hubzilladaily echo " device_mounted=1" >> /var/www/$hubzilladaily echo " echo \"device $backup_device_name is now mounted. Starting backup...\"" >> /var/www/$hubzilladaily -echo " rsnapshot -c $snapshotconfig_external_device alpha" >> /var/www/$hubzilladaily -echo " echo \"\$(date) - disk sizes...\"" >> /var/www/$hubzilladaily -echo " df -h" >> /var/www/$hubzilladaily -echo " echo \"\$(date) - db size...\"" >> /var/www/$hubzilladaily -echo " du -h $backup_mount_point | grep mysql/hubzilla" >> /var/www/$hubzilladaily +echo " rsync -a --delete /var/lib/mysql/ /media/hubzilla_backup/mysql" >> /var/www/$hubzilladaily +echo " rsync -a --delete /var/www/ /media/hubzilla_backup/www" >> /var/www/$hubzilladaily +echo " rsync -a --delete /etc/letsencrypt/ /media/hubzilla_backup/letsencrypt" >> /var/www/$hubzilladaily +echo " echo \"\$(date) - disk sizes...\"" >> /var/www/$hubzilladaily +echo " df -h" >> /var/www/$hubzilladaily +echo " echo \"\$(date) - db size...\"" >> /var/www/$hubzilladaily +echo " du -h $backup_mount_point | grep mysql/hubzilla" >> /var/www/$hubzilladaily echo " echo \"unmounting backup device...\"" >> /var/www/$hubzilladaily echo " umount $backup_mount_point" >> /var/www/$hubzilladaily echo " else" >> /var/www/$hubzilladaily @@ -722,18 +600,16 @@ echo "echo \"\$(date) - db size...\"" >> /var/www/$hubzilladaily echo "du -h /var/lib/mysql/ | grep mysql/hubzilla" >> /var/www/$hubzilladaily echo "#" >> /var/www/$hubzilladaily echo "# update" >> /var/www/$hubzilladaily -echo "echo \"\$(date) - updating dehydrated...\"" >> /var/www/$hubzilladaily -echo "git -C /var/www/letsencrypt/ pull" >> /var/www/$hubzilladaily -echo "echo \"\$(date) - updating hubhilla core...\"" >> /var/www/$hubzilladaily +echo "echo \"\$(date) - updating core and addons...\"" >> /var/www/$hubzilladaily echo "(cd /var/www/html/ ; util/udall)" >> /var/www/$hubzilladaily echo "chown -R www-data:www-data /var/www/html/ # make all accessable for the webserver" >> /var/www/$hubzilladaily echo "chown root:www-data /var/www/html/.htaccess" >> /var/www/$hubzilladaily echo "chmod 0644 /var/www/html/.htaccess # www-data can read but not write it" >> /var/www/$hubzilladaily echo "echo \"\$(date) - updating linux...\"" >> /var/www/$hubzilladaily echo "apt-get -q -y update && apt-get -q -y dist-upgrade && apt-get -q -y autoremove # update linux and upgrade" >> /var/www/$hubzilladaily -echo "echo \"\$(date) - Backup hubzilla and update linux finished. Rebooting...\"" >> /var/www/$hubzilladaily +echo "echo \"\$(date) - Backup and update finished. Rebooting...\"" >> /var/www/$hubzilladaily echo "#" >> /var/www/$hubzilladaily -echo "reboot" >> /var/www/$hubzilladaily +echo "shutdown -r now" >> /var/www/$hubzilladaily if [ -z "`grep 'hubzilla-daily.sh' /etc/crontab`" ] then @@ -745,38 +621,6 @@ echo "reboot" >> /var/www/$hubzilladaily print_info "configured cron for updates/upgrades" } -function write_uninstall_script { - print_info "writing uninstall script..." - - cat > /var/www/hubzilla-remove.sh <<END -#!/bin/sh -# -# This script removes Hubzilla. -# You might do this for a fresh start using the script. -# The script will remove (almost everything) what was installed by the script, -# all applications including hubzilla and its database. -# -# Backup the certificates of letsencrypt (you never know) -cp -a /var/www/letsencrypt/ ~/backup_le_certificats -# -# Removal -apt-get remove apache2 apache2-utils libapache2-mod-php5 php5 php-pear php5-xcache php5-curl php5-mcrypt php5-gd php5-mysql mysql-server mysql-client phpmyadmin -apt-get purge apache2 apache2-utils libapache2-mod-php5 php5 php-pear php5-xcache php5-curl php5-mcrypt php5-gd php5-mysql mysql-server mysql-client phpmyadmin -apt-get autoremove -apt-get clean -rm /etc/rsnapshot_hubzilla.conf -rm /etc/rsnapshot_hubzilla_external_device.conf -rm -R /etc/apache2/ -rm -R /var/lib/mysql/ -rm -R /var/www -rm -R /etc/selfhost/ -# uncomment the next line if you want to remove the backups -# rm -R /var/cache/rsnapshot -nano /etc/crontab # remove entries there manually -END - chmod -x /var/www/hubzilla-remove.sh -} - ######################################################################## # START OF PROGRAM ######################################################################## @@ -792,11 +636,7 @@ selfhostdir=/etc/selfhost selfhostscript=selfhost-updater.sh hubzilladaily=hubzilla-daily.sh plugins_update=.homeinstall/plugins_update.sh -snapshotconfig=/etc/rsnapshot_hubzilla.conf -snapshotconfig_external_device=/etc/rsnapshot_hubzilla_external_device.conf backup_mount_point=/media/hubzilla_backup -le_dir=/var/www/letsencrypt -sslconf=/etc/apache2/sites-available/default-ssl.conf #set -x # activate debugging from here @@ -820,7 +660,6 @@ configure_cron_selfhost if [ "$le_domain" != "localhost" ] then install_letsencrypt - configure_apache_for_https check_https else print_info "is localhost - skipped installation of letsencrypt and configuration of apache for https" @@ -828,20 +667,12 @@ fi install_hubzilla -if [ "$le_domain" != "localhost" ] -then - rewrite_to_https - install_rsnapshot -else - print_info "is localhost - skipped rewrite to https and installation of rsnapshot" -fi - configure_cron_daily if [ "$le_domain" != "localhost" ] then + install_rsync install_cryptosetup - write_uninstall_script else print_info "is localhost - skipped installation of cryptosetup" fi @@ -1,3 +1,14 @@ +Hubzilla 4.0.3 (2019-04-26) + - Add attachments to zot6 event objects + - Add zot6 to federated transports + - Update import/export to handle zot6 hublocs and xchans + - Update fix_system_urls() to handle zot6 hublocs + - Fix infinite loop using postgres as backend + - Fix magic auth in combination with zot6 + - Fix check for required PHP version + - Diaspora: favour diaspora protocol identities over others with same hubloc or xchan address + + Hubzilla 4.0.2 (2019-04-08) - Port cdav calendar to fullcalendar version 4 - Fix perms_pending not evaluated correctly diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 70602bbbc..9bf987027 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -3107,7 +3107,11 @@ class Libzot { foreach($arr as $v) { if($v[$check] === 'zot6') { - + return $v; + } + } + foreach($arr as $v) { + if($v[$check] === 'zot') { return $v; } } diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index a34948489..8985e257a 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -906,6 +906,19 @@ class Cdav extends Controller { $sources = ''; + if(get_pconfig(local_channel(), 'cdav_calendar', 'channel_calendar')) { + $sources .= '{ + id: \'channel_calendar\', + url: \'/channel_calendar/json/\', + color: \'#3a87ad\' + }, '; + } + + $channel_calendars[] = [ + 'displayname' => $channel['channel_name'], + 'id' => 'channel_calendar' + ]; + foreach($calendars as $calendar) { $editable = (($calendar['share-access'] == 2) ? 'false' : 'true'); // false/true must be string since we're passing it to javascript $color = (($calendar['{http://apple.com/ns/ical/}calendar-color']) ? $calendar['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad'); @@ -939,6 +952,19 @@ class Cdav extends Controller { $description = ['description', t('Description')]; $location = ['location', t('Location')]; + $catsenabled = feature_enabled(local_channel(), 'categories'); + + require_once('include/acl_selectors.php'); + + $accesslist = new \Zotlabs\Access\AccessList($channel); + $perm_defaults = $accesslist->get(); + + //$acl = (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'))); + $acl = populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream')); + + //$permissions = ((x($orig_event)) ? $orig_event : $perm_defaults); + $permissions = $perm_defaults; + $o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [ '$sources' => $sources, '$color' => $color, @@ -955,6 +981,7 @@ class Cdav extends Controller { '$list_week' => t('List week'), '$list_day' => t('List day'), '$title' => $title, + '$channel_calendars' => $channel_calendars, '$writable_calendars' => $writable_calendars, '$dtstart' => $dtstart, '$dtend' => $dtend, @@ -964,10 +991,21 @@ class Cdav extends Controller { '$less' => t('Less'), '$update' => t('Update'), '$calendar_select_label' => t('Select calendar'), + '$calendar_optiopns_label' => [t('Channel Calendars'), t('CalDAV Calendars')], '$delete' => t('Delete'), '$delete_all' => t('Delete all'), '$cancel' => t('Cancel'), - '$recurrence_warning' => t('Sorry! Editing of recurrent events is not yet implemented.') + '$recurrence_warning' => t('Sorry! Editing of recurrent events is not yet implemented.'), + + '$channel_hash' => $channel['channel_hash'], + '$acl' => $acl, + '$lockstate' => (($accesslist->is_private()) ? 'lock' : 'unlock'), + '$allow_cid' => acl2json($permissions['allow_cid']), + '$allow_gid' => acl2json($permissions['allow_gid']), + '$deny_cid' => acl2json($permissions['deny_cid']), + '$deny_gid' => acl2json($permissions['deny_gid']), + '$catsenabled' => $catsenabled, + '$categories_label' => t('Categories') ]); return $o; @@ -1054,7 +1092,7 @@ class Cdav extends Controller { } //enable/disable calendars - if(argc() == 5 && argv(1) === 'calendar' && argv(2) === 'switch' && intval(argv(3)) && (argv(4) == 1 || argv(4) == 0)) { + if(argc() == 5 && argv(1) === 'calendar' && argv(2) === 'switch' && argv(3) && (argv(4) == 1 || argv(4) == 0)) { $id = argv(3); if(! cdav_perms($id,$calendars)) diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php new file mode 100644 index 000000000..d47d5ad49 --- /dev/null +++ b/Zotlabs/Module/Channel_calendar.php @@ -0,0 +1,620 @@ +<?php +namespace Zotlabs\Module; + +require_once('include/conversation.php'); +require_once('include/bbcode.php'); +require_once('include/datetime.php'); +require_once('include/event.php'); +require_once('include/items.php'); +require_once('include/html2plain.php'); + +class Channel_calendar extends \Zotlabs\Web\Controller { + + function post() { + + logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA); + + if(! local_channel()) + return; + + if(($_FILES) && array_key_exists('userfile',$_FILES) && intval($_FILES['userfile']['size'])) { + $src = $_FILES['userfile']['tmp_name']; + if($src) { + $result = parse_ical_file($src,local_channel()); + if($result) + info( t('Calendar entries imported.') . EOL); + else + notice( t('No calendar entries found.') . EOL); + @unlink($src); + } + goaway(z_root() . '/channel_calendar'); + } + + + $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); + $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : ''); + + $xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : ''); + $uid = local_channel(); + + $start_text = escape_tags($_REQUEST['dtstart']); + $finish_text = escape_tags($_REQUEST['dtend']); + + $adjust = intval($_POST['adjust']); + $nofinish = intval($_POST['nofinish']); + + $timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : ''); + + $tz = (($timezone) ? $timezone : date_default_timezone_get()); + + $categories = escape_tags(trim($_POST['categories'])); + + // only allow editing your own events. + + if(($xchan) && ($xchan !== get_observer_hash())) + return; + + if($start_text) { + $start = $start_text; + } + else { + $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); + } + + if($finish_text) { + $finish = $finish_text; + } + else { + $finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute); + } + + if($nofinish) { + $finish = NULL_DATE; + } + + + + if($adjust) { + $start = datetime_convert($tz,'UTC',$start); + if(! $nofinish) + $finish = datetime_convert($tz,'UTC',$finish); + } + else { + $start = datetime_convert('UTC','UTC',$start); + if(! $nofinish) + $finish = datetime_convert('UTC','UTC',$finish); + } + + + + // Don't allow the event to finish before it begins. + // It won't hurt anything, but somebody will file a bug report + // and we'll waste a bunch of time responding to it. Time that + // could've been spent doing something else. + + + $summary = escape_tags(trim($_POST['summary'])); + $desc = escape_tags(trim($_POST['desc'])); + $location = escape_tags(trim($_POST['location'])); + $type = escape_tags(trim($_POST['type'])); + + require_once('include/text.php'); + linkify_tags($desc, local_channel()); + linkify_tags($location, local_channel()); + + //$action = ($event_hash == '') ? 'new' : "event/" . $event_hash; + + //fixme: this url gives a wsod if there is a linebreak detected in one of the variables ($desc or $location) + //$onerror_url = z_root() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type"; + //$onerror_url = z_root() . "/events"; + + if(strcmp($finish,$start) < 0 && !$nofinish) { + notice( t('Event can not end before it has started.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } + //goaway($onerror_url); + } + + if((! $summary) || (! $start)) { + notice( t('Event title and start time are required.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } + //goaway($onerror_url); + } + + // $share = ((intval($_POST['distr'])) ? intval($_POST['distr']) : 0); + + $share = 1; + + $channel = \App::get_channel(); + + $acl = new \Zotlabs\Access\AccessList(false); + + if($event_id) { + $x = q("select * from event where id = %d and uid = %d limit 1", + intval($event_id), + intval(local_channel()) + ); + if(! $x) { + notice( t('Event not found.') . EOL); + if(intval($_REQUEST['preview'])) { + echo( t('Unable to generate preview.')); + killme(); + } + return; + } + + $acl->set($x[0]); + + $created = $x[0]['created']; + $edited = datetime_convert(); + + if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>' + && $x[0]['allow_gid'] === '' && $x[0]['deny_cid'] === '' && $x[0]['deny_gid'] === '') { + $share = false; + } + else { + $share = true; + } + } + else { + $created = $edited = datetime_convert(); + if($share) { + $acl->set_from_array($_POST); + } + else { + $acl->set(array('allow_cid' => '<' . $channel['channel_hash'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '')); + } + } + + $post_tags = array(); + $channel = \App::get_channel(); + $ac = $acl->get(); + + if(strlen($categories)) { + $cats = explode(',',$categories); + foreach($cats as $cat) { + $post_tags[] = array( + 'uid' => $profile_uid, + 'ttype' => TERM_CATEGORY, + 'otype' => TERM_OBJ_POST, + 'term' => trim($cat), + 'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) + ); + } + } + + $datarray = array(); + $datarray['dtstart'] = $start; + $datarray['dtend'] = $finish; + $datarray['summary'] = $summary; + $datarray['description'] = $desc; + $datarray['location'] = $location; + $datarray['etype'] = $type; + $datarray['adjust'] = $adjust; + $datarray['nofinish'] = $nofinish; + $datarray['uid'] = local_channel(); + $datarray['account'] = get_account_id(); + $datarray['event_xchan'] = $channel['channel_hash']; + $datarray['allow_cid'] = $ac['allow_cid']; + $datarray['allow_gid'] = $ac['allow_gid']; + $datarray['deny_cid'] = $ac['deny_cid']; + $datarray['deny_gid'] = $ac['deny_gid']; + $datarray['private'] = (($acl->is_private()) ? 1 : 0); + $datarray['id'] = $event_id; + $datarray['created'] = $created; + $datarray['edited'] = $edited; + + if(intval($_REQUEST['preview'])) { + $html = format_event_html($datarray); + echo $html; + killme(); + } + + $event = event_store_event($datarray); + + if($post_tags) + $datarray['term'] = $post_tags; + + $item_id = event_store_item($datarray,$event); + + if($item_id) { + $r = q("select * from item where id = %d", + intval($item_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", + dbesc($r[0]['resource_id']), + intval($channel['channel_id']) + ); + if($z) { + build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); + } + } + } + + if($share) + \Zotlabs\Daemon\Master::Summon(array('Notifier','event',$item_id)); + + killme(); + + } + + + + function get() { + + if(argc() > 2 && argv(1) == 'ical') { + $event_id = argv(2); + + require_once('include/security.php'); + $sql_extra = permissions_sql(local_channel()); + + $r = q("select * from event where event_hash = '%s' $sql_extra limit 1", + dbesc($event_id) + ); + if($r) { + header('Content-type: text/calendar'); + header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"' ); + echo ical_wrapper($r); + killme(); + } + else { + notice( t('Event not found.') . EOL ); + return; + } + } + + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return; + } + + if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) { + $r = q("update event set dismissed = 1 where id = %d and uid = %d", + intval(argv(2)), + intval(local_channel()) + ); + } + + if((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) { + $r = q("update event set dismissed = 0 where id = %d and uid = %d", + intval(argv(2)), + intval(local_channel()) + ); + } + + $channel = \App::get_channel(); + + $mode = 'view'; + $y = 0; + $m = 0; + $ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : ''); + + if(argc() > 1) { + if(argc() > 2 && argv(1) === 'add') { + $mode = 'add'; + $item_id = intval(argv(2)); + } + if(argc() > 2 && argv(1) === 'drop') { + $mode = 'drop'; + $event_id = argv(2); + } + if(argc() > 2 && intval(argv(1)) && intval(argv(2))) { + $mode = 'view'; + $y = intval(argv(1)); + $m = intval(argv(2)); + } + if(argc() <= 2) { + $mode = 'view'; + $event_id = argv(1); + } + } + + if($mode === 'add') { + event_addtocal($item_id,local_channel()); + killme(); + } + + if($mode == 'view') { + + /* edit/create form */ + if($event_id) { + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($event_id), + intval(local_channel()) + ); + if(count($r)) + $orig_event = $r[0]; + } + + $channel = \App::get_channel(); + + // Passed parameters overrides anything found in the DB + if(!x($orig_event)) + $orig_event = array(); + + $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); + $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); + $t_orig = ((x($orig_event)) ? $orig_event['summary'] : ''); + $d_orig = ((x($orig_event)) ? $orig_event['description'] : ''); + $l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); + $eid = ((x($orig_event)) ? $orig_event['id'] : 0); + $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']); + $mid = ((x($orig_event)) ? $orig_event['mid'] : ''); + + $sdt = ((x($orig_event)) ? $orig_event['dtstart'] : 'now'); + + $fdt = ((x($orig_event)) ? $orig_event['dtend'] : '+1 hour'); + + $tz = date_default_timezone_get(); + if(x($orig_event)) + $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); + + $syear = datetime_convert('UTC', $tz, $sdt, 'Y'); + $smonth = datetime_convert('UTC', $tz, $sdt, 'm'); + $sday = datetime_convert('UTC', $tz, $sdt, 'd'); + $shour = datetime_convert('UTC', $tz, $sdt, 'H'); + $sminute = datetime_convert('UTC', $tz, $sdt, 'i'); + + $stext = datetime_convert('UTC',$tz,$sdt); + $stext = substr($stext,0,14) . "00:00"; + + $fyear = datetime_convert('UTC', $tz, $fdt, 'Y'); + $fmonth = datetime_convert('UTC', $tz, $fdt, 'm'); + $fday = datetime_convert('UTC', $tz, $fdt, 'd'); + $fhour = datetime_convert('UTC', $tz, $fdt, 'H'); + $fminute = datetime_convert('UTC', $tz, $fdt, 'i'); + + $ftext = datetime_convert('UTC',$tz,$fdt); + $ftext = substr($ftext,0,14) . "00:00"; + + $type = ((x($orig_event)) ? $orig_event['etype'] : 'event'); + + $f = get_config('system','event_input_format'); + if(! $f) + $f = 'ymd'; + + $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); + $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); + if(! $y) + $y = intval($thisyear); + if(! $m) + $m = intval($thismonth); + + $export = false; + if(argc() === 4 && argv(3) === 'export') + $export = true; + + // Put some limits on dates. The PHP date functions don't seem to do so well before 1900. + // An upper limit was chosen to keep search engines from exploring links millions of years in the future. + + if($y < 1901) + $y = 1900; + if($y > 2099) + $y = 2100; + + $nextyear = $y; + $nextmonth = $m + 1; + if($nextmonth > 12) { + $nextmonth = 1; + $nextyear ++; + } + + $prevyear = $y; + if($m > 1) + $prevmonth = $m - 1; + else { + $prevmonth = 12; + $prevyear --; + } + + $dim = get_dim($y,$m); + $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0); + $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59); + + + if (argv(1) === 'json'){ + if (x($_GET,'start')) $start = $_GET['start']; + if (x($_GET,'end')) $finish = $_GET['end']; + } + + $start = datetime_convert('UTC','UTC',$start); + $finish = datetime_convert('UTC','UTC',$finish); + + $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); + $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); + + if (x($_GET,'id')){ + $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan + from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d limit 1", + intval(local_channel()), + intval($_GET['id']) + ); + } elseif($export) { + $r = q("SELECT * from event where uid = %d + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", + intval(local_channel()), + dbesc($start), + dbesc($finish), + dbesc($adjust_start), + dbesc($adjust_finish) + ); + } + else { + // fixed an issue with "nofinish" events not showing up in the calendar. + // There's still an issue if the finish date crosses the end of month. + // Noting this for now - it will need to be fixed here and in Friendica. + // Ultimately the finish date shouldn't be involved in the query. + + $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id + from event left join item on event_hash = resource_id + where resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", + intval(local_channel()), + dbesc($start), + dbesc($finish), + dbesc($adjust_start), + dbesc($adjust_finish) + ); + + + } + + $links = array(); + + if($r && ! $export) { + xchan_query($r); + $r = fetch_post_tags($r,true); + + $r = sort_by_date($r); + } + + if($r) { + foreach($r as $rr) { + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); + if(! x($links,$j)) + $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j; + } + } + + $events=array(); + + $last_date = ''; + $fmt = t('l, F j'); + + if($r) { + + foreach($r as $rr) { + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); + $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt)); + $d = day_translate($d); + + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c')); + if ($rr['nofinish']){ + $end = null; + } else { + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c')); + + // give a fake end to birthdays so they get crammed into a + // single day on the calendar + + if($rr['etype'] === 'birthday') + $end = null; + } + + $catsenabled = feature_enabled(local_channel(),'categories'); + $categories = ''; + if($catsenabled){ + if($rr['term']) { + $cats = get_terms_oftype($rr['term'], TERM_CATEGORY); + foreach ($cats as $cat) { + if(strlen($categories)) + $categories .= ', '; + $categories .= $cat['term']; + } + } + } + + $is_first = ($d !== $last_date); + + $last_date = $d; + + $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false); + + $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); + + $title = strip_tags(html_entity_decode(zidify_links(bbcode($rr['summary'])),ENT_QUOTES,'UTF-8')); + if(! $title) { + list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); + $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8')); + } + $html = format_event_html($rr); + $rr['desc'] = zidify_links(smilies(bbcode($rr['desc']))); + $rr['description'] = htmlentities(html2plain(bbcode($rr['description'])),ENT_COMPAT,'UTF-8',false); + $rr['location'] = zidify_links(smilies(bbcode($rr['location']))); + $events[] = array( + 'calendar_id' => 'channel_calendar', + 'rw' => true, + + 'id'=>$rr['id'], + 'uri' => $rr['event_hash'], + 'start'=> $start, + 'end' => $end, + 'drop' => $drop, + 'allDay' => false, + 'title' => $title, + + 'j' => $j, + 'd' => $d, + 'is_editable' => $edit ? true : false, + + 'is_first'=>$is_first, + 'item'=>$rr, + 'html'=>$html, + 'plink' => array($rr['plink'],t('Link to Source'),'',''), + + 'description' => $rr['description'], + 'location' => $rr['location'], + + 'allow_cid' => expand_acl($rr['allow_cid']), + 'allow_gid' => expand_acl($rr['allow_gid']), + 'deny_cid' => expand_acl($rr['deny_cid']), + 'deny_gid' => expand_acl($rr['deny_gid']), + + 'categories' => $categories + ); + } + } + + if($export) { + header('Content-type: text/calendar'); + header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' ); + echo ical_wrapper($r); + killme(); + } + + if (\App::$argv[1] === 'json'){ + json_return_and_die($events); + } + } + + + if($mode === 'drop' && $event_id) { + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($event_id), + intval(local_channel()) + ); + + $sync_event = $r[0]; + + if($r) { + $r = q("delete from event where event_hash = '%s' and uid = %d", + dbesc($event_id), + intval(local_channel()) + ); + if($r) { + $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d", + dbesc($event_id), + intval(local_channel()) + ); + $sync_event['event_deleted'] = 1; + build_sync_packet(0,array('event' => array($sync_event))); + killme(); + } + notice( t('Failed to remove event' ) . EOL); + killme(); + } + } + + } + +} diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 1c9068e07..85882bf0a 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -45,7 +45,8 @@ class Editpost extends \Zotlabs\Web\Controller { } if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) { - goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1'); + goaway(z_root() . '/cdav/calendar'); + //goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1'); } $owner_uid = $itm[0]['uid']; diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index a48c690a7..18cb5560e 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -280,8 +280,9 @@ class Import extends \Zotlabs\Web\Controller { // replace any existing xchan we may have on this site if we're seizing control - $r = q("delete from xchan where xchan_hash = '%s'", - dbesc($channel['channel_hash']) + $r = q("delete from xchan where ( xchan_hash = '%s' or xchan_hash = '%s' ) ", + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) ); $r = xchan_store_lowlevel( @@ -303,6 +304,30 @@ class Import extends \Zotlabs\Web\Controller { 'xchan_name_date' => datetime_convert() ] ); + + if($channel['channel_portable_id']) { + $r = xchan_store_lowlevel( + [ + 'xchan_hash' => \Zotlabs\Lib\Libzot::make_xchan_hash($channel['channel_guid'],$channel['channel_pubkey']), + 'xchan_guid' => $channel['channel_guid'], + 'xchan_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'xchan_pubkey' => $channel['channel_pubkey'], + 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'], + 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'], + 'xchan_photo_s' => z_root() . "/photo/profile/s/" . $channel['channel_id'], + 'xchan_addr' => channel_reddress($channel), + 'xchan_url' => z_root() . '/channel/' . $channel['channel_address'], + 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'], + 'xchan_follow' => z_root() . '/follow?f=&url=%s', + 'xchan_name' => $channel['channel_name'], + 'xchan_network' => 'zot6', + 'xchan_photo_date' => datetime_convert(), + 'xchan_name_date' => datetime_convert() + ] + ); + } + + } logger('import step 6'); @@ -312,10 +337,20 @@ class Import extends \Zotlabs\Web\Controller { if($xchans) { foreach($xchans as $xchan) { - $hash = make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_guid_sig']); - if($xchan['xchan_network'] === 'zot' && $hash !== $xchan['xchan_hash']) { - logger('forged xchan: ' . print_r($xchan,true)); - continue; + if($xchan['xchan_network'] === 'zot') { + $hash = make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_guid_sig']); + if($hash !== $xchan['xchan_hash']) { + logger('forged xchan: ' . print_r($xchan,true)); + continue; + } + } + + if($xchan['xchan_network'] === 'zot6') { + $zhash = \Zotlabs\Lib\Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']); + if($zhash !== $xchan['xchan_hash']) { + logger('forged xchan: ' . print_r($xchan,true)); + continue; + } } if(! array_key_exists('xchan_hidden',$xchan)) { diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 71737eef8..e8e960574 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -169,8 +169,8 @@ class Magic extends \Zotlabs\Web\Controller { $token = $j['token']; } - $x = strpbrk($dest,'?&'); - $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); + $strp = strpbrk($dest,'?&'); + $args = (($strp) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); goaway($dest . $args); } } diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index ad57f883c..cf116a96c 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -30,12 +30,29 @@ class Owa extends \Zotlabs\Web\Controller { $keyId = $sigblock['keyId']; if($keyId) { + + // Hubzilla connections can have both zot and zot6 hublocs + // The connections will usually be zot so match those first + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) ", + where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot' ", dbesc(str_replace('acct:','',$keyId)), dbesc($keyId) ); - if(! $r) { + + // If nothing was found, try searching on any network + + if (! $r) { + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash + where ( hubloc_addr = '%s' or hubloc_id_url = '%s' )", + dbesc(str_replace('acct:','',$keyId)), + dbesc($keyId) + ); + } + + // If nothing was found on any network, use network discovery and create a new record + + if (! $r) { $found = discover_by_webbie(str_replace('acct:','',$keyId)); if($found) { $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash @@ -45,7 +62,8 @@ class Owa extends \Zotlabs\Web\Controller { ); } } - if($r) { + + if ($r) { foreach($r as $hubloc) { $verified = \Zotlabs\Web\HTTPSig::verify(file_get_contents('php://input'),$hubloc['xchan_pubkey']); if($verified && $verified['header_signed'] && $verified['header_valid']) { @@ -53,7 +71,7 @@ class Owa extends \Zotlabs\Web\Controller { logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA); $ret['success'] = true; $token = random_string(32); - \Zotlabs\Lib\Verify::create('owt',0,$token,$hubloc['hubloc_addr']); + \Zotlabs\Lib\Verify::create('owt',0,$token,$hubloc['hubloc_network'] . ',' . $hubloc['hubloc_addr']); $result = ''; openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); $ret['encrypted_token'] = base64url_encode($result); diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a367b1062..f0c3a8821 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -447,7 +447,7 @@ class Ping extends \Zotlabs\Web\Controller { $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); $result[] = array( - 'notify_link' => z_root() . '/events', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], + 'notify_link' => z_root() . '/cdav/calendar', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], 'name' => $rr['xchan_name'], 'addr' => $rr['xchan_addr'], 'url' => $rr['xchan_url'], diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index c809ff5ec..541e4fa21 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -377,7 +377,7 @@ class Setup extends \Zotlabs\Web\Controller { if(version_compare(PHP_VERSION, '7.1') < 0) { $help .= t('PHP version 7.1 or greater is required.'); - $this->check_add($checks, t('PHP version'), false, false, $help); + $this->check_add($checks, t('PHP version'), false, true, $help); } if(strlen($phpath)) { diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 03275abbc..a19bdbedc 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -128,7 +128,7 @@ class Wfinger extends \Zotlabs\Web\Controller { 'http://webfinger.net/ns/name' => $r[0]['channel_name'], 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name'], 'https://w3id.org/security/v1#publicKeyPem' => $r[0]['xchan_pubkey'], - 'http://purl.org/zot/federation' => 'zot' + 'http://purl.org/zot/federation' => 'zot,zot6' ]; foreach($aliases as $alias) diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php index 589f915c5..c88530c0b 100644 --- a/Zotlabs/Widget/Cdav.php +++ b/Zotlabs/Widget/Cdav.php @@ -113,10 +113,22 @@ class Cdav { } } + $channel_calendars[] = [ + 'ownernick' => $channel['channel_address'], + 'displayname' => $channel['channel_name'], + 'calendarid' => 'channel_calendar', + 'json_source' => '/channel_calendar/json', + 'color' => '#3a87ad', + 'editable' => true, + 'switch' => get_pconfig(local_channel(), 'cdav_calendar', 'channel_calendar') + ]; + $o .= replace_macros(get_markup_template('cdav_widget_calendar.tpl'), [ - '$my_calendars_label' => t('My Calendars'), + '$channel_calendars_label' => t('Channel Calendar'), + '$channel_calendars' => $channel_calendars, + '$my_calendars_label' => t('CalDAV Calendars'), '$my_calendars' => $my_calendars, - '$shared_calendars_label' => t('Shared Calendars'), + '$shared_calendars_label' => t('Shared CalDAV Calendars'), '$shared_calendars' => $shared_calendars, '$sharee_options' => $sharee_options, '$access_options' => $access_options, @@ -127,7 +139,7 @@ class Cdav { '$create_label' => t('Create new calendar'), '$create' => t('Create'), '$create_placeholder' => t('Calendar Name'), - '$tools_label' => t('Calendar Tools'), + '$tools_label' => t('CalDAV Calendar Tools'), '$import_label' => t('Import calendar'), '$import_placeholder' => t('Select a calendar to import to'), '$upload' => t('Upload'), @@ -1507,12 +1507,13 @@ function fix_system_urls($oldurl, $newurl) { dbesc($rv['xchan_hash']) ); - $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'", + $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'", dbesc($channel_address . '@' . $rhs), dbesc($newurl), - dbesc(base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))), + dbesc(str_replace($oldurl,$newurl,$rv['hubloc_id_url'])), + dbesc(($rv['hubloc_network'] === 'zot6') ? \Zotlabs\Lib\Libzot::sign($newurl,$c[0]['channel_prvkey']) : base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))), dbesc($newhost), - dbesc($newurl . '/post'), + dbesc(($rv['hubloc_network'] === 'zot6') ? $newurl . '/zot' : $newurl . '/post'), dbesc($rv['xchan_hash']), dbesc($oldurl) ); diff --git a/composer.lock b/composer.lock index 2631b8dac..27449f451 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "blueimp/jquery-file-upload", - "version": "v9.28.0", + "version": "v9.30.0", "source": { "type": "git", "url": "https://github.com/vkhramtsov/jQuery-File-Upload.git", - "reference": "ff5accfe2e5c4a522777faa980a90cf86a636d1d" + "reference": "1fceec556879403e5c1ae32a7c448aa12b8c3558" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vkhramtsov/jQuery-File-Upload/zipball/ff5accfe2e5c4a522777faa980a90cf86a636d1d", - "reference": "ff5accfe2e5c4a522777faa980a90cf86a636d1d", + "url": "https://api.github.com/repos/vkhramtsov/jQuery-File-Upload/zipball/1fceec556879403e5c1ae32a7c448aa12b8c3558", + "reference": "1fceec556879403e5c1ae32a7c448aa12b8c3558", "shasum": "" }, "type": "library", @@ -59,7 +59,7 @@ "upload", "widget" ], - "time": "2018-11-13T05:41:39+00:00" + "time": "2019-04-22T09:21:57+00:00" }, { "name": "bshaffer/oauth2-server-php", @@ -861,16 +861,16 @@ }, { "name": "sabre/vobject", - "version": "4.1.6", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/sabre-io/vobject.git", - "reference": "122cacbdea2c6133ac04db86ec05854beef75adf" + "reference": "bd500019764e434ff65872d426f523e7882a0739" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/vobject/zipball/122cacbdea2c6133ac04db86ec05854beef75adf", - "reference": "122cacbdea2c6133ac04db86ec05854beef75adf", + "url": "https://api.github.com/repos/sabre-io/vobject/zipball/bd500019764e434ff65872d426f523e7882a0739", + "reference": "bd500019764e434ff65872d426f523e7882a0739", "shasum": "" }, "require": { @@ -879,8 +879,7 @@ "sabre/xml": ">=1.5 <3.0" }, "require-dev": { - "phpunit/phpunit": "> 4.8.35, <6.0.0", - "sabre/cs": "^1.0.0" + "phpunit/phpunit": "> 4.8.35, <6.0.0" }, "suggest": { "hoa/bench": "If you would like to run the benchmark scripts" @@ -954,7 +953,7 @@ "xCal", "xCard" ], - "time": "2018-04-20T07:22:50+00:00" + "time": "2019-02-19T13:05:37+00:00" }, { "name": "sabre/xml", diff --git a/doc/admin/administrator_guide.md b/doc/admin/administrator_guide.md index 2b1c84180..c884bb0bd 100644 --- a/doc/admin/administrator_guide.md +++ b/doc/admin/administrator_guide.md @@ -1,4 +1,3 @@ - ### Overview $Projectname is more than a simple web application. It is a @@ -17,48 +16,47 @@ such as XAMPP and WAMP are not officially supported at this time however we welcome patches if you manage to get it working. ### Where to find more help -If you encounter problems or have issues not addressed in this documentation, +If you encounter problems or have issues not addressed in this documentation, please let us know via the [Github issue tracker](https://framagit.org/hubzilla/core/issues). Please be as clear as you can about your operating environment and provide as much detail as possible about any error messages you may see, so that we can prevent it from happening in the future. Due to the large variety of operating systems and PHP platforms in existence we may have only limited ability to debug your PHP installation or -acquire any missing modules * but we will do our best to solve any general code +acquire any missing modules, but we will do our best to solve any general code issues. -### Before you begin +### Before you begin #### Choose a domain name or subdomain name for your server -$Projectname can only be installed into the root of a domain or sub-domain, and can +$Projectname can only be installed into the root of a domain or sub-domain, and can not be installed using alternate TCP ports. #### Decide if you will use SSL and obtain an SSL certificate before software installation -You SHOULD use SSL. If you use SSL, you MUST use a "browser-valid" certificate. +You SHOULD use SSL. If you use SSL, you MUST use a "browser-valid" certificate. *You MUST NOT use self-signed certificates!* -Please test your certificate prior to installation. A web tool for testing your -certificate is available at "http://www.digicert.com/help/". When visiting your -site for the first time, please use the SSL ("https://") URL if SSL is available. -This will avoid problems later. The installation routine will not allow you to +Please test your certificate prior to installation. A web tool for testing your +certificate is available at "http://www.digicert.com/help/". When visiting your +site for the first time, please use the SSL ("https://") URL if SSL is available. +This will avoid problems later. The installation routine will not allow you to use a non browser-valid certificate. - -This restriction is incorporated because public posts from you may contain +This restriction is incorporated because public posts from you may contain references to images on your own hub. Other members viewing their stream on other hubs will get warnings if your certificate is not trusted by their web browser. This will confuse many people because this is a decentralised network -and they will get the warning about your hub while viewing their own hub and may -think their own hub has an issue. These warnings are very technical and scary to +and they will get the warning about your hub while viewing their own hub and may +think their own hub has an issue. These warnings are very technical and scary to some folks, many of whom will not know how to proceed except to follow the browser advice. This is disruptive to the community. That said, we recognise the issues surrounding the current certificate infrastructure and agree there are many -problems, but that doesn't change the requirement. +problems, but that doesn't change the requirement. Free "browser-valid" certificates are available from providers such as StartSSL -and LetsEncrypt. +and LetsEncrypt. If you do NOT use SSL, there may be a delay of up to a minute for the initial install script - while we check the SSL port to see if anything responds there. @@ -66,11 +64,11 @@ When communicating with new sites, $Projectname always attempts connection on th SSL port first, before falling back to a less secure connection. If you do not use SSL, your webserver MUST NOT listen on port 443 at all. -If you use LetsEncrypt to provide certificates and create a file under -.well-known/acme-challenge so that LetsEncrypt can verify your domain ownership, -please remove or rename the .well-known directory as soon as the certificate is +If you use LetsEncrypt to provide certificates and create a file under +.well-known/acme-challenge so that LetsEncrypt can verify your domain ownership, +please remove or rename the .well-known directory as soon as the certificate is generated. $Projectname will provide its own handler for ".well-known" services when -it is installed, and an existing directory in this location may prevent some of +it is installed, and an existing directory in this location may prevent some of these services from working correctly. This should not be a problem with Apache, but may be an issue with nginx or other web server platforms. @@ -82,20 +80,20 @@ There are several ways to deploy a new hub. * Automated deployment using an OpenShift virtual private server (VPS) ### Requirements -* Apache with mod-rewrite enabled and "AllowOverride All" so you can use a +* Apache with mod-rewrite enabled and "AllowOverride All" so you can use a local .htaccess file. Some folks have successfully used nginx and lighttpd. Example config scripts are available for these platforms in doc/install. - Apache and nginx have the most support. + Apache and nginx have the most support. -* PHP 5.5 or later. - * Note that on some shared hosting environments, the _command line_ version of -PHP might differ from the _webserver_ version +* PHP 7.1 or later. + * Note that on some shared hosting environments, the _command line_ + version of PHP might differ from the _webserver_ version -* PHP *command line* access with register_argc_argv set to true in the - php.ini file * and with no hosting provider restrictions on the use of +* PHP *command line* access with register_argc_argv set to true in the + php.ini file * and with no hosting provider restrictions on the use of exec() and proc_open(). -* curl, gd (with at least jpeg and png support), mysqli, mbstring, mcrypt, zip, +* curl, gd (with at least jpeg and png support), mysqli, mbstring, mcrypt, zip, and openssl extensions. The imagick extension is not required but desirable. * xml extension is required if you want webdav to work. @@ -106,7 +104,7 @@ PHP might differ from the _webserver_ version * ability to schedule jobs with cron. -* Installation into a top-level domain or sub-domain (without a +* Installation into a top-level domain or sub-domain (without a directory/path component in the URL) is REQUIRED. ### Manual Installation @@ -115,9 +113,9 @@ PHP might differ from the _webserver_ version If you copy the directory tree to your webserver, make sure that you include the hidden files like .htaccess. -If you are able to do so, we recommend using git to clone the source -repository rather than to use a packaged tar or zip file. This makes the -software much easier to update. The Linux command to clone the repository +If you are able to do so, we recommend using git to clone the source +repository rather than to use a packaged tar or zip file. This makes the +software much easier to update. The Linux command to clone the repository into a directory "mywebsite" would be: git clone https://framagit.org/hubzilla/core.git mywebsite @@ -126,7 +124,7 @@ and then you can pick up the latest changes at any time with: git pull -make sure folders ``store/[data]/smarty3`` and ``store`` exist and are +make sure folders ``store/[data]/smarty3`` and ``store`` exist and are writable by the webserver: mkdir -p "store/[data]/smarty3" @@ -150,7 +148,7 @@ web-based administrative tools to function: #### Official addons ##### Installation -Navigate to your website. Then you should clone the addon repository (separately). We'll give this repository a nickname of 'hzaddons'. You can pull in other hubzilla addon repositories by giving them different nicknames:: +Navigate to your website. Then you should clone the addon repository (separately). We'll give this repository a nickname of 'hzaddons'. You can pull in other hubzilla addon repositories by giving them different nicknames: cd mywebsite util/add_addon_repo https://framagit.org/hubzilla/addons.git hzaddons @@ -161,9 +159,9 @@ For keeping the addon tree updated, you should be on your top level website dire cd mywebsite util/update_addon_repo hzaddons -Create searchable representations of the online documentation. You may do this -any time that the documentation is updated : - +Create searchable representations of the online documentation. You may do this +any time that the documentation is updated : + cd mywebsite util/importdoc @@ -203,45 +201,28 @@ We recommend the following addons be installed on all public sites: Several web communities have begun to converge using common protocols. The protocols involved are somewhat limited in their abilities. The GNU-Social protocol for instance offers no privacy modes, and the Diaspora protocol is somewhat restrictive in what kinds of communications are allowed. All comments must be signed in a very unique manner by the original author. The ActivityPub protocol is also being considered and may be supported at a future date. No other existing protocol supports nomadic location as used by this project. This presents some support challenges as some features work with some networks and don't work with others. Nevertheless the federation protocols allow connections to be made to a much larger community of people worldwide. They are provided as addons. -> diaspora - The Diaspora Protocol used by Diaspora and Friendica. You should enable 'Diaspora Statistics' (statistics) first to enable all the available features. +* diaspora - The Diaspora Protocol used by Diaspora and Friendica. You should enable 'Diaspora Statistics' (statistics) first to enable all the available features. -> gnusoc - The GNU-Social Protocol, used by GNU-Social, Mastodon and several other communities. This addon requires you first install the 'pubsubhubbub' service (also an addon). +* gnusoc - The GNU-Social Protocol, used by GNU-Social, Mastodon and several other communities. This addon requires you first install the 'pubsubhubbub' service (also an addon). Each member of your site must choose whether or not to allow these protocols individually as they may conflict with several desirable core features and abilities of this software (such as channel migration and cloning). They do this from their 'Settings -> Feature/Addon Settings' page. The administrator may also set the following: util/config system.diaspora_allowed 1 util/config system.gnusoc_allowed 1 -and enable these protocols automatically for all newly created channels. - - - - - - -### Techlevels - -We've implemented several different mechanisms in order to reduce the apparent complexity and learning curve presented to new members. At the same time, we do not wish to limit any functionality for people who are able to grasp some slightly advanced technical technical features. The first mechanism was to move several features to an optional 'Features' page where they could be enabled at will; with the default interface kept somewhat lean. - -The problem we had now is that the number of features began to grow dramatically, and the Feature page is daunting in possibilities. There are also features present which probably should not be available to all members, but may be extremely useful to those with technical backgrounds. - -The techlevels seeeks to remedy this by grouping features within different levels of technical ability; starting at 0 (uncomfortable with technology), and up to 5 (Unix wizard or equivalent). - -When a new member registers, their account is provided a techlevel setting of 0. On the account settings page they may change this to any available level. A higher level opens more advanced features and possible interactions. - -The account administrator may also lock a particular level, lock a maximum level, or change/re-arrange the features available to any level. Those with the minimum level are typically not very exploratory and are unlikely to discover the advanced modes. This is by design. Those that look around and desire more interactions will find them. In the absence of administrator defaults they may choose any level. As they look at the features available to the level in question, it is generally expected that they will discover some features are beyond their comprehension and it is hoped they will back off to a level where the interface and features are comfortable to their skill level. +and enable these protocols automatically for all newly created channels. ### Service Classes Service classes allow you to set limits on system resources by limiting what individual -accounts can do, including file storage and top-level post limits. Define custom service -classes according to your needs in the `.htconfig.php` file. For example, create +accounts can do, including file storage and top-level post limits. Define custom service +classes according to your needs in the `.htconfig.php` file. For example, create a _standard_ and _premium_ class using the following lines: // Service classes - + App::$config['system']['default_service_class']='standard'; // this is the default service class that is attached to every new account - + // configuration for standard service class App::$config['service_class']['standard'] = array('photo_upload_limit'=>2097152, // total photo storage limit per channel (here 2MB) @@ -251,7 +232,7 @@ a _standard_ and _premium_ class using the following lines: 'total_channels' =>100, // number of channels the user can add, other users can still add this channel, even if the limit is reached 'attach_upload_limit' =>2097152, // total attachment storage limit per channel (here 2MB) 'chatters_inroom' =>20); - + // configuration for premium service class App::$config['service_class']['premium'] = array('photo_upload_limit'=>20000000000, // total photo storage limit per channel (here 20GB) @@ -262,7 +243,7 @@ a _standard_ and _premium_ class using the following lines: 'attach_upload_limit' =>20000000000, // total attachment storage limit per channel (here 20GB) 'chatters_inroom' =>100); -To apply a service class to an existing account, use the command line utility from the +To apply a service class to an existing account, use the command line utility from the web root: `util/service_class` @@ -298,11 +279,11 @@ set the account that owns channel 'blogchan' to service class 'firstclass' (with * access_tokens - maximum number of Guest Access Tokens per channel ### Theme management -#### Repo management example +#### Repo management example 1. Navigate to your hub web root ``` - root@hub:/root# cd /var/www + root@hub:/root# cd /var/www ``` 2. Add the theme repo and give it a name @@ -319,70 +300,136 @@ set the account that owns channel 'blogchan' to service class 'firstclass' (with #### Keywords -There is a "tag cloud" of keywords that can appear on the channel directory page. -If you wish to hide these keywords, which are drawn from the directory server, you +There is a "tag cloud" of keywords that can appear on the channel directory page. +If you wish to hide these keywords, which are drawn from the directory server, you can use the *config* tool: util/config system disable_directory_keywords 1 - -If your hub is in the standalone mode because you do not wish to connect to the -global grid, you may instead ensure the the _directory_server_ system option is + +If your hub is in the standalone mode because you do not wish to connect to the +global grid, you may instead ensure the the _directory_server_ system option is empty: util/config system directory_server "" - ### Administration #### Site Administration -Administration of the website is commonly done through the admin webpage located at /admin on your website. In order to access this page you must have administration rights to the server. Administration rights are granted to the first account to register on your site, **provided** the email address of that account exactly matches the email address you provided as the administrator's email address during setup. +Administration of the website is commonly done through the admin webpage located at /admin on your website. In order to access this page you must have administration rights to the server. Administration rights are granted to the first account to register on your site, **provided** the email address of that account exactly matches the email address you provided as the administrator's email address during setup. -There are several ways that this can fail and leave the system without an administrator account, for instance if the first account that was created provided a different email address than the administrator email address that was supplied during setup. +There are several ways that this can fail and leave the system without an administrator account, for instance if the first account that was created provided a different email address than the administrator email address that was supplied during setup. For security reasons there is no web page or interface on the system which will give you administrator access. If you need to correct a situation where a system has no administrator account it **must** be done by editing the account table in the database. There is no other way. To do this, you will need to locate the entry in the account table which belongs to the desired administrator, and set 'account_roles' for that entry to 4096. You will then be able to access the admin page from your system's profile menu or directly via /admin . -A hub can have multiple admins and there is no limit to how administrators you can have. Repeat the above process for every account you wish to provide with administration rights. - +A hub can have multiple admins and there is no limit to how administrators you can have. Repeat the above process for every account you wish to provide with administration rights. ### Troubleshooting #### Log files -The system logfile is an extremely useful resource for tracking down things that go wrong. This can be enabled in the admin/log configuration page. A loglevel setting of LOGGER_DEBUG is preferred for stable production sites. Most things that go wrong with communications or storage are listed here. A setting of LOGGER_DATA provides [b]much[/b] more detail, but may fill your disk. In either case we recommend the use of logrotate on your operating system to cycle logs and discard older entries. - -At the bottom of your .htconfig.php file are several lines (commented out) which enable PHP error logging. This reports issues with code syntax and executing the code and is the first place you should look for issues which result in a "white screen" or blank page. This is typically the result of code/syntax problems. -Database errors are reported to the system logfile, but we've found it useful to have a file in your top-level directory called dbfail.out which [b]only[/b] collects database related issues. If the file exists and is writable, database errors will be logged to it as well as to the system logfile. - -In the case of "500" errors, the issues may often be logged in your webserver logs, often /var/log/apache2/error.log or something similar. Consult your operating system documentation. +The system logfile is an extremely useful resource for tracking down +things that go wrong. This can be enabled in the admin/log +configuration page. A loglevel setting of `LOGGER_DEBUG` is preferred +for stable production sites. Most things that go wrong with +communications or storage are listed here. A setting of LOGGER_DATA +provides *much* more detail, but may fill your disk. In either +case we recommend the use of logrotate on your operating system to +cycle logs and discard older entries. + +At the bottom of your .htconfig.php file are several lines (commented +out) which enable PHP error logging. This reports issues with code +syntax and executing the code and is the first place you should look +for issues which result in a "white screen" or blank page. This is +typically the result of code/syntax problems. Database errors are +reported to the system logfile, but we've found it useful to have a +file in your top-level directory called dbfail.out which *only* +collects database related issues. If the file exists and is writable, +database errors will be logged to it as well as to the system logfile. + +In the case of "500" errors, the issues may often be logged in your +webserver logs, often /var/log/apache2/error.log or something +similar. Consult your operating system documentation. There are three different log facilities. -**The first is the database failure log**. This is only used if you create a file called specifically 'dbfail.out' in the root folder of your website and make it write-able by the web server. If we have any database failed queries, they are all reported here. They generally indicate typos in our queries, but also occur if the database server disconnects or tables get corrupted. On rare occasions we'll see race conditions in here where two processes tried to create an xchan or cache entry with the same ID. Any other errors (especially persistent errors) should be investigated. - -**The second is the PHP error log**. This is created by the language processor and only reports issues in the language environment. Again these can be syntax errors or programming errors, but these generally are fatal and result in a "white screen of death"; e.g. PHP terminates. You should probably look at this file if something goes wrong that doesn't result in a white screen of death, but it isn't uncommon for this file to be empty for days on end. - -There are some lines at the bottom of the supplied .htconfig.php file; which if uncommented will enable a PHP error log (*extremely* useful for finding the source of white screen failures). This isn't done by default due to potential issues with logfile ownership and write permissions and the fact that there is no logfile rotation by default. - - -**The third is the "application log"**. This is used by $Projectname to report what is going on in the program and usually reports any difficulties or unexpected data we received. It also occasionally reports "heartbeat" status messages to indicate that we reached a certain point in a script. **This** is the most important log file to us, as we create it ourself for the sole purpose of reporting the status of background tasks and anything that seems weird or out of place. It may not be fatal, but maybe just unexpected. If you're performing a task and there's a problem, let us know what is in this file when the problem occurred. (Please don't send me 100M dumps you'll only piss me off). Just a few relevant lines so I can rule out a few hundred thousand lines of code and concentrate on where the problem starts showing up. +**The first is the database failure log**. This is only used if you + create a file called specifically `dbfail.out` in the root folder of + your website and make it write-able by the web server. If we have + any database failed queries, they are all reported here. They + generally indicate typos in our queries, but also occur if the + database server disconnects or tables get corrupted. On rare + occasions we'll see race conditions in here where two processes + tried to create an xchan or cache entry with the same ID. Any other + errors (especially persistent errors) should be investigated. + +**The second is the PHP error log**. This is created by the language + processor and only reports issues in the language environment. Again + these can be syntax errors or programming errors, but these + generally are fatal and result in a "white screen of death"; + e.g. PHP terminates. You should probably look at this file if + something goes wrong that doesn't result in a white screen of death, + but it isn't uncommon for this file to be empty for days on end. + + There are some lines at the bottom of the supplied `.htconfig.php` + file; which if uncommented will enable a PHP error log (*extremely* + useful for finding the source of white screen failures). This isn't + done by default due to potential issues with logfile ownership and + write permissions and the fact that there is no logfile rotation by + default. + +**The third is the "application log"**. This is used by $Projectname + to report what is going on in the program and usually reports any + difficulties or unexpected data we received. It also occasionally + reports "heartbeat" status messages to indicate that we reached a + certain point in a script. **This** is the most important log file + to us, as we create it ourself for the sole purpose of reporting the + status of background tasks and anything that seems weird or out of + place. It may not be fatal, but maybe just unexpected. If you're + performing a task and there's a problem, let us know what is in this + file when the problem occurred. (Please don't send me 100M dumps + you'll only piss me off). Just a few relevant lines so I can rule + out a few hundred thousand lines of code and concentrate on where + the problem starts showing up. + +These are your site logs, not mine. We report serious issues at any +log level. I highly recommend `DEBUG` log level for most sites - which +provides a bit of additional info and doesn't create huge +logfiles. When there's a problem which defies all attempts to track, +you might wish to use `DATA` log level for a short period of time to +capture all the detail of what structures we were dealing with at the +time. This log level will use a lot of space so is recommended only +for brief periods or for developer test sites. + +I recommend configuring logrotate for both the php log and the +application log. I usually have a look at dbfail.out every week or +two, fix any issues reported and then starting over with a fresh +file. Likewise with the PHP logfile. I refer to it once in a while to +see if there's something that needs fixing. + +If something goes wrong, and it's not a fatal error, I look at the +application logfile. Often I will -These are your site logs, not mine. We report serious issues at any log level. I highly recommend 'DEBUG' log level for most sites - which provides a bit of additional info and doesn't create huge logfiles. When there's a problem which defies all attempts to track, you might wish to use DATA log level for a short period of time to capture all the detail of what structures we were dealing with at the time. This log level will use a lot of space so is recommended only for brief periods or for developer test sites. - -I recommend configuring logrotate for both the php log and the application log. I usually have a look at dbfail.out every week or two, fix any issues reported and then starting over with a fresh file. Likewise with the PHP logfile. I refer to it once in a while to see if there's something that needs fixing. - -If something goes wrong, and it's not a fatal error, I look at the application logfile. Often I will ``` -tail -f logfile.out +tail -f logfile.out ``` -While repeating an operation that has problems. Often I'll insert extra logging statements in the code if there isn't any hint what's going wrong. Even something as simple as "got here" or printing out the value of a variable that might be suspect. You can do this too - in fact I encourage you to do so. Once you've found what you need to find, you can +While repeating an operation that has problems. Often I'll insert +extra logging statements in the code if there isn't any hint what's +going wrong. Even something as simple as "got here" or printing out +the value of a variable that might be suspect. You can do this too - +in fact I encourage you to do so. Once you've found what you need to +find, you can ``` git checkout file.php ``` -To immediately clear out all the extra logging stuff you added. Use the information from this log and any detail you can provide from your investigation of the problem to file your bug report - unless your analysis points to the source of the problem. In that case, just fix it. +To immediately clear out all the extra logging stuff you added. Use +the information from this log and any detail you can provide from your +investigation of the problem to file your bug report - unless your +analysis points to the source of the problem. In that case, just fix +it. ##### Rotating log files @@ -390,13 +437,25 @@ To immediately clear out all the extra logging stuff you added. Use the informa 1. Create a directory in your web root called `log` with webserver write permissions 1. Go to the **logrot** admin settings and enter this folder name as well as the max size and number of retained log files. - #### Reporting issues -When reporting issues, please try to provide as much detail as may be necessary for developers to reproduce the issue and provide the complete text of all error messages. - -We encourage you to try to the best of your abilities to use these logs combined with the source code in your possession to troubleshoot issues and find their cause. The community is often able to help, but only you have access to your site logfiles and it is considered a security risk to share them. - -If a code issue has been uncovered, please report it on the project bugtracker (https://framagit.org/hubzilla/core/issues). Again provide as much detail as possible to avoid us going back and forth asking questions about your configuration or how to duplicate the problem, so that we can get right to the problem and figure out what to do about it. You are also welcome to offer your own solutions and submit patches. In fact we encourage this as we are all volunteers and have little spare time available. The more people that help, the easier the workload for everybody. It's OK if your solution isn't perfect. Every little bit helps and perhaps we can improve on it. - - +When reporting issues, please try to provide as much detail as may be +necessary for developers to reproduce the issue and provide the +complete text of all error messages. + +We encourage you to try to the best of your abilities to use these +logs combined with the source code in your possession to troubleshoot +issues and find their cause. The community is often able to help, but +only you have access to your site logfiles and it is considered a +security risk to share them. + +If a code issue has been uncovered, please report it on the project +bugtracker (https://framagit.org/hubzilla/core/issues). Again provide +as much detail as possible to avoid us going back and forth asking +questions about your configuration or how to duplicate the problem, so +that we can get right to the problem and figure out what to do about +it. You are also welcome to offer your own solutions and submit +patches. In fact we encourage this as we are all volunteers and have +little spare time available. The more people that help, the easier the +workload for everybody. It's OK if your solution isn't perfect. Every +little bit helps and perhaps we can improve on it. diff --git a/include/channel.php b/include/channel.php index 654bbdb05..e4b6df47b 100644 --- a/include/channel.php +++ b/include/channel.php @@ -873,6 +873,13 @@ function identity_basic_export($channel_id, $sections = null) { $ret['abook'][$x]['abconfig'] = $abconfig; translate_abook_perms_outbound($ret['abook'][$x]); } + + // pick up the zot6 xchan and hublocs also + + if($ret['channel']['channel_portable_id']) { + $xchans[] = $ret['channel']['channel_portable_id']; + } + stringify_array_elms($xchans); } @@ -1812,13 +1819,16 @@ function zid_init() { call_hooks('zid_init', $arr); if(! local_channel()) { - $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1", + $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc", dbesc($tmp_str) ); if(! $r) { Master::Summon(array('Gprobe',bin2hex($tmp_str))); } - if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash']) + if($r) { + $r = zot_record_preferred($r); + } + if($r && remote_channel() && remote_channel() === $r['hubloc_hash']) return; logger('Not authenticated. Invoking reverse magic-auth for ' . $tmp_str); @@ -1826,8 +1836,8 @@ function zid_init() { $query = App::$query_string; $query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query); $dest = '/' . $query; - if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) { - goaway($r[0]['hubloc_url'] . '/magic' . '?f=&rev=1&owa=1&bdest=' . bin2hex(z_root() . $dest)); + if($r && ($r['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) { + goaway($r['hubloc_url'] . '/magic' . '?f=&rev=1&owa=1&bdest=' . bin2hex(z_root() . $dest)); } else logger('No hubloc found.'); diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index a70e4a1d7..0279342ec 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -161,23 +161,17 @@ class dba_pdo extends dba_driver { } function unescapebin($str) { - if($this->driver_dbtype === 'pgsql' && (! is_null($str))) { - $x = ''; - while(! feof($str)) { - $x .= fread($str,8192); + if($this->driver_dbtype === 'pgsql') { + if(gettype($str) === 'resource') { + $str = stream_get_contents($str); } - if(substr($x,0,2) === '\\x') { - $x = hex2bin(substr($x,2)); + if(substr($str,0,2) === '\\x') { + $str = hex2bin(substr($str,2)); } - return $x; - - } - else { - return $str; } + return $str; } - function getdriver() { return 'pdo'; } diff --git a/include/event.php b/include/event.php index fdb9e1415..cfca00a3c 100644 --- a/include/event.php +++ b/include/event.php @@ -4,8 +4,11 @@ * @brief Event related functions. */ + use Sabre\VObject; +use Zotlabs\Lib\Activity; + use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; @@ -65,7 +68,7 @@ function format_event_html($ev) { } function format_event_obj($jobject) { - $event = array(); + $event = []; $object = json_decode($jobject,true); @@ -1046,6 +1049,7 @@ function event_store_item($arr, $event) { 'location' => $arr['location'], 'adjust' => $arr['adjust'], 'content' => format_event_bbcode($arr), + 'attachment' => Activity::encode_attachment($r[0]), 'author' => array( 'name' => $r[0]['xchan_name'], 'address' => $r[0]['xchan_addr'], @@ -1200,6 +1204,7 @@ function event_store_item($arr, $event) { 'location' => $arr['location'], 'adjust' => $arr['adjust'], 'content' => format_event_bbcode($arr), + 'attachment' => Activity::encode_attachment($item_arr), 'author' => array( 'name' => $x[0]['xchan_name'], 'address' => $x[0]['xchan_addr'], @@ -1279,6 +1284,10 @@ function cdav_principal($uri) { } function cdav_perms($needle, $haystack, $check_rw = false) { + + if($needle == 'channel_calendar') + return true; + foreach ($haystack as $item) { if($check_rw) { if(is_array($item['id'])) { diff --git a/include/zid.php b/include/zid.php index 0b12689ef..ed79de76a 100644 --- a/include/zid.php +++ b/include/zid.php @@ -1,5 +1,6 @@ <?php +use Zotlabs\Lib\Verify; function is_matrix_url($url) { @@ -270,34 +271,45 @@ function red_zrlify_img_callback($matches) { */ function owt_init($token) { - \Zotlabs\Lib\Verify::purge('owt', '3 MINUTE'); + Verify::purge('owt', '3 MINUTE'); - $ob_hash = \Zotlabs\Lib\Verify::get_meta('owt', 0, $token); + $key = Verify::get_meta('owt', 0, $token); - if($ob_hash === false) { + if($key === false) { + return; + } + + $parts = explode(',',$key,2); + if(count($parts) < 2) { return; } $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash - where hubloc_addr = '%s' order by hubloc_id desc", - dbesc($ob_hash) + where hubloc_network = '%s' and hubloc_addr = '%s' order by hubloc_id desc", + dbesc($parts[0]), + dbesc($parts[1]) ); if(! $r) { + // finger them if they can't be found. - $j = \Zotlabs\Zot\Finger::run($ob_hash, null); + // @todo check that this is still needed. Discovery should have been performed in the Owa module. + + $j = \Zotlabs\Zot\Finger::run($parts[1], null); if ($j['success']) { import_xchan($j); $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash - where hubloc_addr = '%s' order by hubloc_id desc", - dbesc($ob_hash) + where hubloc_network = '%s' and hubloc_addr = '%s' order by hubloc_id desc", + dbesc($parts[0]), + dbesc($parts[1]) ); } } if(! $r) { - logger('owt: unable to finger ' . $ob_hash); + logger('owt: unable to finger ' . $key); return; } + $hubloc = $r[0]; $_SESSION['authenticated'] = 1; @@ -324,7 +336,7 @@ function owt_init($token) { if (! $delegate_success) { // normal visitor (remote_channel) login session credentials $_SESSION['visitor_id'] = $hubloc['xchan_hash']; - $_SESSION['my_url'] = $hubloc['xchan_url']; + $_SESSION['my_url'] = $hubloc['xchan_url']; $_SESSION['my_address'] = $hubloc['hubloc_addr']; $_SESSION['remote_hub'] = $hubloc['hubloc_url']; $_SESSION['DNT'] = 1; @@ -332,7 +344,7 @@ function owt_init($token) { $arr = [ 'xchan' => $hubloc, - 'url' => \App::$query_string, + 'url' => App::$query_string, 'session' => $_SESSION ]; /** @@ -344,11 +356,11 @@ function owt_init($token) { */ call_hooks('magic_auth_success', $arr); - \App::set_observer($hubloc); + App::set_observer($hubloc); require_once('include/security.php'); - \App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); + App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); if(! get_config('system', 'hide_owa_greeting')) - info(sprintf( t('OpenWebAuth: %1$s welcomes %2$s'),\App::get_hostname(), $hubloc['xchan_name'])); + info(sprintf( t('OpenWebAuth: %1$s welcomes %2$s'),App::get_hostname(), $hubloc['xchan_name'])); logger('OpenWebAuth: auth success from ' . $hubloc['xchan_addr']); } @@ -384,7 +396,9 @@ function observer_auth($ob_hash) { return; } - $hubloc = $r[0]; + // Note: this has no Libzot namespace so prefers zot over zot6 + + $hubloc = zot_record_preferred($r); $_SESSION['authenticated'] = 1; @@ -395,8 +409,8 @@ function observer_auth($ob_hash) { $_SESSION['remote_hub'] = $hubloc['hubloc_url']; $_SESSION['DNT'] = 1; - \App::set_observer($hubloc); + App::set_observer($hubloc); require_once('include/security.php'); - \App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); + App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); } diff --git a/include/zot.php b/include/zot.php index 9f2321bc4..983b73072 100644 --- a/include/zot.php +++ b/include/zot.php @@ -5286,3 +5286,25 @@ function zot_reply_notify($data) { $ret['success'] = true; json_return_and_die($ret); } + + +function zot_record_preferred($arr, $check = 'hubloc_network') { + + if(! $arr) { + return $arr; + } + + foreach($arr as $v) { + if($v[$check] === 'zot') { + return $v; + } + } + foreach($arr as $v) { + if($v[$check] === 'zot6') { + return $v; + } + } + + return $arr[0]; + +} diff --git a/vendor/blueimp/jquery-file-upload/SECURITY.md b/vendor/blueimp/jquery-file-upload/SECURITY.md index 86ffc163b..3e3d3a610 100644 --- a/vendor/blueimp/jquery-file-upload/SECURITY.md +++ b/vendor/blueimp/jquery-file-upload/SECURITY.md @@ -128,6 +128,6 @@ To do so, locate the ImageMagick `policy.xml` configuration file and add the fol <!-- ... --> <policy domain="delegate" rights="none" pattern="*" /> <policy domain="coder" rights="none" pattern="*" /> - <policy domain="coder" rights="read | write" pattern="{GIF,JPEG,PNG}" /> + <policy domain="coder" rights="read | write" pattern="{GIF,JPEG,JPG,PNG}" /> </policymap> ``` diff --git a/vendor/blueimp/jquery-file-upload/bower.json b/vendor/blueimp/jquery-file-upload/bower.json index 2a56262a1..a5d439147 100644 --- a/vendor/blueimp/jquery-file-upload/bower.json +++ b/vendor/blueimp/jquery-file-upload/bower.json @@ -1,6 +1,6 @@ { "name": "blueimp-file-upload", - "version": "9.28.0", + "version": "9.30.0", "title": "jQuery File Upload", "description": "File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images.", "keywords": [ diff --git a/vendor/blueimp/jquery-file-upload/index.html b/vendor/blueimp/jquery-file-upload/index.html index 37e08a7cb..68ed83717 100644 --- a/vendor/blueimp/jquery-file-upload/index.html +++ b/vendor/blueimp/jquery-file-upload/index.html @@ -149,7 +149,9 @@ <span class="preview"></span> </td> <td> - <p class="name">{%=file.name%}</p> + {% if (window.innerWidth > 480 || !o.options.loadImageFileTypes.test(file.type)) { %} + <p class="name">{%=file.name%}</p> + {% } %} <strong class="error text-danger"></strong> </td> <td> @@ -185,13 +187,15 @@ </span> </td> <td> - <p class="name"> - {% if (file.url) { %} - <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a> - {% } else { %} - <span>{%=file.name%}</span> - {% } %} - </p> + {% if (window.innerWidth > 480 || !file.thumbnailUrl) { %} + <p class="name"> + {% if (file.url) { %} + <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a> + {% } else { %} + <span>{%=file.name%}</span> + {% } %} + </p> + {% } %} {% if (file.error) { %} <div><span class="label label-danger">Error</span> {%=file.error%}</div> {% } %} diff --git a/vendor/blueimp/jquery-file-upload/jquery-ui.html b/vendor/blueimp/jquery-file-upload/jquery-ui.html index e44d41e89..017169d38 100644 --- a/vendor/blueimp/jquery-file-upload/jquery-ui.html +++ b/vendor/blueimp/jquery-file-upload/jquery-ui.html @@ -154,7 +154,9 @@ <span class="preview"></span> </td> <td> - <p class="name">{%=file.name%}</p> + {% if (window.innerWidth > 480 || !o.options.loadImageFileTypes.test(file.type)) { %} + <p class="name">{%=file.name%}</p> + {% } %} <strong class="error"></strong> </td> <td> @@ -184,9 +186,11 @@ </span> </td> <td> - <p class="name"> - <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a> - </p> + {% if (window.innerWidth > 480 || !file.thumbnailUrl) { %} + <p class="name"> + <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a> + </p> + {% } %} {% if (file.error) { %} <div><span class="error">Error</span> {%=file.error%}</div> {% } %} diff --git a/vendor/blueimp/jquery-file-upload/package.json b/vendor/blueimp/jquery-file-upload/package.json index 0a635397c..7db22a104 100644 --- a/vendor/blueimp/jquery-file-upload/package.json +++ b/vendor/blueimp/jquery-file-upload/package.json @@ -1,6 +1,6 @@ { "name": "blueimp-file-upload", - "version": "9.28.0", + "version": "9.30.0", "title": "jQuery File Upload", "description": "File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.", "keywords": [ diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index ba7b1d85c..5f66fc00c 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -919,6 +919,7 @@ return array( 'Zotlabs\\Module\\Cdav' => $baseDir . '/Zotlabs/Module/Cdav.php', 'Zotlabs\\Module\\Changeaddr' => $baseDir . '/Zotlabs/Module/Changeaddr.php', 'Zotlabs\\Module\\Channel' => $baseDir . '/Zotlabs/Module/Channel.php', + 'Zotlabs\\Module\\Channel_calendar' => $baseDir . '/Zotlabs/Module/Channel_calendar.php', 'Zotlabs\\Module\\Chanview' => $baseDir . '/Zotlabs/Module/Chanview.php', 'Zotlabs\\Module\\Chat' => $baseDir . '/Zotlabs/Module/Chat.php', 'Zotlabs\\Module\\Chatsvc' => $baseDir . '/Zotlabs/Module/Chatsvc.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 37a73de45..83708e296 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -1087,6 +1087,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'Zotlabs\\Module\\Cdav' => __DIR__ . '/../..' . '/Zotlabs/Module/Cdav.php', 'Zotlabs\\Module\\Changeaddr' => __DIR__ . '/../..' . '/Zotlabs/Module/Changeaddr.php', 'Zotlabs\\Module\\Channel' => __DIR__ . '/../..' . '/Zotlabs/Module/Channel.php', + 'Zotlabs\\Module\\Channel_calendar' => __DIR__ . '/../..' . '/Zotlabs/Module/Channel_calendar.php', 'Zotlabs\\Module\\Chanview' => __DIR__ . '/../..' . '/Zotlabs/Module/Chanview.php', 'Zotlabs\\Module\\Chat' => __DIR__ . '/../..' . '/Zotlabs/Module/Chat.php', 'Zotlabs\\Module\\Chatsvc' => __DIR__ . '/../..' . '/Zotlabs/Module/Chatsvc.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7f829f6a4..31646bc24 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,20 +1,20 @@ [ { "name": "blueimp/jquery-file-upload", - "version": "v9.28.0", - "version_normalized": "9.28.0.0", + "version": "v9.30.0", + "version_normalized": "9.30.0.0", "source": { "type": "git", "url": "https://github.com/vkhramtsov/jQuery-File-Upload.git", - "reference": "ff5accfe2e5c4a522777faa980a90cf86a636d1d" + "reference": "1fceec556879403e5c1ae32a7c448aa12b8c3558" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vkhramtsov/jQuery-File-Upload/zipball/ff5accfe2e5c4a522777faa980a90cf86a636d1d", - "reference": "ff5accfe2e5c4a522777faa980a90cf86a636d1d", + "url": "https://api.github.com/repos/vkhramtsov/jQuery-File-Upload/zipball/1fceec556879403e5c1ae32a7c448aa12b8c3558", + "reference": "1fceec556879403e5c1ae32a7c448aa12b8c3558", "shasum": "" }, - "time": "2018-11-13T05:41:39+00:00", + "time": "2019-04-22T09:21:57+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -886,17 +886,17 @@ }, { "name": "sabre/vobject", - "version": "4.1.6", - "version_normalized": "4.1.6.0", + "version": "4.2.0", + "version_normalized": "4.2.0.0", "source": { "type": "git", "url": "https://github.com/sabre-io/vobject.git", - "reference": "122cacbdea2c6133ac04db86ec05854beef75adf" + "reference": "bd500019764e434ff65872d426f523e7882a0739" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/vobject/zipball/122cacbdea2c6133ac04db86ec05854beef75adf", - "reference": "122cacbdea2c6133ac04db86ec05854beef75adf", + "url": "https://api.github.com/repos/sabre-io/vobject/zipball/bd500019764e434ff65872d426f523e7882a0739", + "reference": "bd500019764e434ff65872d426f523e7882a0739", "shasum": "" }, "require": { @@ -905,13 +905,12 @@ "sabre/xml": ">=1.5 <3.0" }, "require-dev": { - "phpunit/phpunit": "> 4.8.35, <6.0.0", - "sabre/cs": "^1.0.0" + "phpunit/phpunit": "> 4.8.35, <6.0.0" }, "suggest": { "hoa/bench": "If you would like to run the benchmark scripts" }, - "time": "2018-04-20T07:22:50+00:00", + "time": "2019-02-19T13:05:37+00:00", "bin": [ "bin/vobject", "bin/generate_vcards" diff --git a/vendor/sabre/vobject/.gitignore b/vendor/sabre/vobject/.gitignore index 95935f798..f08b31359 100644 --- a/vendor/sabre/vobject/.gitignore +++ b/vendor/sabre/vobject/.gitignore @@ -16,6 +16,7 @@ bin/hoa # Development stuff testdata/ +.php_cs.cache # OS X .DS_Store diff --git a/vendor/sabre/vobject/.php_cs.dist b/vendor/sabre/vobject/.php_cs.dist new file mode 100644 index 000000000..8d61ee259 --- /dev/null +++ b/vendor/sabre/vobject/.php_cs.dist @@ -0,0 +1,12 @@ +<?php + +$config = PhpCsFixer\Config::create(); +$config->getFinder() + ->exclude('vendor') + ->in(__DIR__); +$config->setRules([ + '@PSR1' => true, + '@Symfony' =>true +]); + +return $config;
\ No newline at end of file diff --git a/vendor/sabre/vobject/.travis.yml b/vendor/sabre/vobject/.travis.yml index 531ad5be4..2619562ab 100644 --- a/vendor/sabre/vobject/.travis.yml +++ b/vendor/sabre/vobject/.travis.yml @@ -1,20 +1,39 @@ language: php +sudo: required php: - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 + - 7.3 -sudo: false +env: + global: + - RUN_PHPSTAN="FALSE" -script: - - ./bin/phpunit --configuration tests/phpunit.xml - - ./bin/sabre-cs-fixer fix . --dry-run --diff +matrix: + include: + - name: 'PHPStan' + php: 7.2 + env: RUN_PHPSTAN="TRUE" + fast_finish: true + allow_failures: + - php: 5.5 + +install: + - if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.10.3/phpstan.phar; fi before_script: - composer install +script: + - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml; fi + - if [ $RUN_PHPSTAN == "TRUE" ]; then php phpstan.phar analyse -c phpstan.neon lib; fi + +after_success: + - bash <(curl -s https://codecov.io/bash) + cache: directories: - $HOME/.composer/cache diff --git a/vendor/sabre/vobject/CHANGELOG.md b/vendor/sabre/vobject/CHANGELOG.md index 6cfec988e..7a2c935fb 100644 --- a/vendor/sabre/vobject/CHANGELOG.md +++ b/vendor/sabre/vobject/CHANGELOG.md @@ -1,6 +1,19 @@ ChangeLog ========= +4.2.0 (2019-02-19) +------------------ + +* #432: DTSTAMP must be specified in UTC +* #435: ORGANIZER e-mail address are case-insensitive +* #441: Repairing BASE64 encoded vCard version 3 + +4.2.0-alpha1 (2018-09-26) +------------------------- + +* #412: Broker: add timezone to CANCEL messages +* #424: Support php7.3 + 4.1.6 (2018-04-20) ------------------ @@ -29,7 +42,7 @@ ChangeLog * #363: Repair script and de-duplicate properties that are only allowed once, but appear more than once. (@ddolcimascolo). -* #377: Addes Pacific Time (US & Canada) as exchange timezone +* #377: Added Pacific Time (US & Canada) as exchange timezone * #384: Added fallback for VCards without `FN` diff --git a/vendor/sabre/vobject/bin/bench.php b/vendor/sabre/vobject/bin/bench.php index 807b40777..0a2736fa6 100644 --- a/vendor/sabre/vobject/bin/bench.php +++ b/vendor/sabre/vobject/bin/bench.php @@ -1,7 +1,7 @@ #!/usr/bin/env php <?php -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; $data = stream_get_contents(STDIN); @@ -9,4 +9,4 @@ $start = microtime(true); $lol = Sabre\VObject\Reader::read($data); -echo "time: " . (microtime(true) - $start) . "\n"; +echo 'time: '.(microtime(true) - $start)."\n"; diff --git a/vendor/sabre/vobject/bin/bench_freebusygenerator.php b/vendor/sabre/vobject/bin/bench_freebusygenerator.php index 2c51b2a32..1299c14fb 100644 --- a/vendor/sabre/vobject/bin/bench_freebusygenerator.php +++ b/vendor/sabre/vobject/bin/bench_freebusygenerator.php @@ -1,16 +1,16 @@ <?php -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; if ($argc < 2) { - echo "sabre/vobject ", Sabre\VObject\Version::VERSION, " freebusy benchmark\n"; + echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " freebusy benchmark\n"; echo "\n"; echo "This script can be used to measure the speed of generating a\n"; echo "free-busy report based on a calendar.\n"; echo "\n"; echo "The process will be repeated 100 times to get accurate stats\n"; echo "\n"; - echo "Usage: " . $argv[0] . " inputfile.ics\n"; + echo 'Usage: '.$argv[0]." inputfile.ics\n"; die(); } @@ -30,33 +30,24 @@ $timeZone = new \DateTimeZone('America/Toronto'); $bench->fb->start(); -for ($i = 0; $i < $repeat; $i++) { - +for ($i = 0; $i < $repeat; ++$i) { $fb = new Sabre\VObject\FreeBusyGenerator($start, $end, $vcal, $timeZone); $results = $fb->getResult(); - } $bench->fb->stop(); - - echo $bench,"\n"; -function formatMemory($input) { - +function formatMemory($input) +{ if (strlen($input) > 6) { - - return round($input / (1024 * 1024)) . 'M'; - + return round($input / (1024 * 1024)).'M'; } elseif (strlen($input) > 3) { - - return round($input / 1024) . 'K'; - + return round($input / 1024).'K'; } - } unset($input, $splitter); -echo "peak memory usage: " . formatMemory(memory_get_peak_usage()), "\n"; -echo "current memory usage: " . formatMemory(memory_get_usage()), "\n"; +echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n"; +echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n"; diff --git a/vendor/sabre/vobject/bin/bench_manipulatevcard.php b/vendor/sabre/vobject/bin/bench_manipulatevcard.php index adc198e9b..f229091db 100644 --- a/vendor/sabre/vobject/bin/bench_manipulatevcard.php +++ b/vendor/sabre/vobject/bin/bench_manipulatevcard.php @@ -1,15 +1,15 @@ <?php -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; if ($argc < 2) { - echo "sabre/vobject ", Sabre\VObject\Version::VERSION, " manipulation benchmark\n"; + echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " manipulation benchmark\n"; echo "\n"; echo "This script can be used to measure the speed of opening a large amount of\n"; echo "vcards, making a few alterations and serializing them again.\n"; - echo "system."; + echo 'system.'; echo "\n"; - echo "Usage: " . $argv[0] . " inputfile.vcf\n"; + echo 'Usage: '.$argv[0]." inputfile.vcf\n"; die(); } @@ -22,18 +22,21 @@ $splitter = new Sabre\VObject\Splitter\VCard($input); $bench = new Hoa\Bench\Bench(); while (true) { - $bench->parse->start(); $vcard = $splitter->getNext(); $bench->parse->pause(); - if (!$vcard) break; + if (!$vcard) { + break; + } $bench->manipulate->start(); $vcard->{'X-FOO'} = 'Random new value!'; $emails = []; - if (isset($vcard->EMAIL)) foreach ($vcard->EMAIL as $email) { - $emails[] = (string)$email; + if (isset($vcard->EMAIL)) { + foreach ($vcard->EMAIL as $email) { + $emails[] = (string) $email; + } } $bench->manipulate->pause(); @@ -42,28 +45,20 @@ while (true) { $bench->serialize->pause(); $vcard->destroy(); - } - - echo $bench,"\n"; -function formatMemory($input) { - +function formatMemory($input) +{ if (strlen($input) > 6) { - - return round($input / (1024 * 1024)) . 'M'; - + return round($input / (1024 * 1024)).'M'; } elseif (strlen($input) > 3) { - - return round($input / 1024) . 'K'; - + return round($input / 1024).'K'; } - } unset($input, $splitter); -echo "peak memory usage: " . formatMemory(memory_get_peak_usage()), "\n"; -echo "current memory usage: " . formatMemory(memory_get_usage()), "\n"; +echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n"; +echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n"; diff --git a/vendor/sabre/vobject/bin/fetch_windows_zones.php b/vendor/sabre/vobject/bin/fetch_windows_zones.php index 3f2a00f7a..9c4e51abd 100644 --- a/vendor/sabre/vobject/bin/fetch_windows_zones.php +++ b/vendor/sabre/vobject/bin/fetch_windows_zones.php @@ -2,9 +2,9 @@ <?php $windowsZonesUrl = 'http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml'; -$outputFile = __DIR__ . '/../lib/timezonedata/windowszones.php'; +$outputFile = __DIR__.'/../lib/timezonedata/windowszones.php'; -echo "Fetching timezone map from: " . $windowsZonesUrl, "\n"; +echo 'Fetching timezone map from: '.$windowsZonesUrl, "\n"; $data = file_get_contents($windowsZonesUrl); @@ -13,16 +13,14 @@ $xml = simplexml_load_string($data); $map = []; foreach ($xml->xpath('//mapZone') as $mapZone) { - - $from = (string)$mapZone['other']; - $to = (string)$mapZone['type']; + $from = (string) $mapZone['other']; + $to = (string) $mapZone['type']; list($to) = explode(' ', $to, 2); if (!isset($map[$from])) { $map[$from] = $to; } - } ksort($map); @@ -33,19 +31,19 @@ fwrite($f, "<?php\n\n"); fwrite($f, "/**\n"); fwrite($f, " * Automatically generated timezone file\n"); fwrite($f, " *\n"); -fwrite($f, " * Last update: " . date(DATE_W3C) . "\n"); -fwrite($f, " * Source: " . $windowsZonesUrl . "\n"); +fwrite($f, ' * Last update: '.date(DATE_W3C)."\n"); +fwrite($f, ' * Source: '.$windowsZonesUrl."\n"); fwrite($f, " *\n"); fwrite($f, " * @copyright Copyright (C) fruux GmbH (https://fruux.com/).\n"); fwrite($f, " * @license http://sabre.io/license/ Modified BSD License\n"); fwrite($f, " */\n"); fwrite($f, "\n"); -fwrite($f, "return "); -fwrite($f, var_export($map, true) . ';'); +fwrite($f, 'return '); +fwrite($f, var_export($map, true).';'); fclose($f); echo "Formatting\n"; -exec(__DIR__ . '/sabre-cs-fixer fix ' . escapeshellarg($outputFile)); +exec(__DIR__.'/sabre-cs-fixer fix '.escapeshellarg($outputFile)); echo "Done\n"; diff --git a/vendor/sabre/vobject/bin/generateicalendardata.php b/vendor/sabre/vobject/bin/generateicalendardata.php index a2df3c63a..62b6107c5 100644 --- a/vendor/sabre/vobject/bin/generateicalendardata.php +++ b/vendor/sabre/vobject/bin/generateicalendardata.php @@ -23,54 +23,53 @@ HI $events = 100; -if (isset($argv[1])) $events = (int)$argv[1]; +if (isset($argv[1])) { + $events = (int) $argv[1]; +} -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; -fwrite(STDERR, "Generating " . $events . " events\n"); +fwrite(STDERR, 'Generating '.$events." events\n"); -$currentDate = new DateTime('-' . round($events / 2) . ' days'); +$currentDate = new DateTime('-'.round($events / 2).' days'); $calendar = new VObject\Component\VCalendar(); $ii = 0; while ($ii < $events) { - - $ii++; + ++$ii; $event = $calendar->add('VEVENT'); $event->DTSTART = 'bla'; - $event->SUMMARY = 'Event #' . $ii; + $event->SUMMARY = 'Event #'.$ii; $event->UID = md5(microtime(true)); $doctorRandom = mt_rand(1, 1000); switch ($doctorRandom) { // All-day event - case 1 : + case 1: $event->DTEND = 'bla'; $dtStart = clone $currentDate; $dtEnd = clone $currentDate; - $dtEnd->modify('+' . mt_rand(1, 3) . ' days'); + $dtEnd->modify('+'.mt_rand(1, 3).' days'); $event->DTSTART->setDateTime($dtStart); $event->DTSTART['VALUE'] = 'DATE'; $event->DTEND->setDateTime($dtEnd); break; - case 2 : - $event->RRULE = 'FREQ=DAILY;COUNT=' . mt_rand(1, 10); - // No break intentional - default : + case 2: + $event->RRULE = 'FREQ=DAILY;COUNT='.mt_rand(1, 10); + // no break intentional + default: $dtStart = clone $currentDate; $dtStart->setTime(mt_rand(1, 23), mt_rand(0, 59), mt_rand(0, 59)); $event->DTSTART->setDateTime($dtStart); - $event->DURATION = 'PT' . mt_rand(1, 3) . 'H'; + $event->DURATION = 'PT'.mt_rand(1, 3).'H'; break; - } - - $currentDate->modify('+ ' . mt_rand(0, 3) . ' days'); + $currentDate->modify('+ '.mt_rand(0, 3).' days'); } fwrite(STDERR, "Validating\n"); diff --git a/vendor/sabre/vobject/bin/mergeduplicates.php b/vendor/sabre/vobject/bin/mergeduplicates.php index 076524d36..e6cde73dd 100644 --- a/vendor/sabre/vobject/bin/mergeduplicates.php +++ b/vendor/sabre/vobject/bin/mergeduplicates.php @@ -6,8 +6,8 @@ namespace Sabre\VObject; // This sucks.. we have to try to find the composer autoloader. But chances // are, we can't find it this way. So we'll do our bestest $paths = [ - __DIR__ . '/../vendor/autoload.php', // In case vobject is cloned directly - __DIR__ . '/../../../autoload.php', // In case vobject is a composer dependency. + __DIR__.'/../vendor/autoload.php', // In case vobject is cloned directly + __DIR__.'/../../../autoload.php', // In case vobject is a composer dependency. ]; foreach ($paths as $path) { @@ -22,14 +22,12 @@ if (!class_exists('Sabre\\VObject\\Version')) { die(1); } -echo "sabre/vobject ", Version::VERSION, " duplicate contact merge tool\n"; +echo 'sabre/vobject ', Version::VERSION, " duplicate contact merge tool\n"; if ($argc < 3) { - echo "\n"; - echo "Usage: ", $argv[0], " input.vcf output.vcf [debug.log]\n"; + echo 'Usage: ', $argv[0], " input.vcf output.vcf [debug.log]\n"; die(1); - } $input = fopen($argv[1], 'r'); @@ -42,83 +40,72 @@ $splitter = new Splitter\VCard($input); // but not in others, we don't consider them for the sake of finding // differences. $ignoredProperties = [ - "PRODID", - "VERSION", - "REV", - "UID", - "X-ABLABEL", + 'PRODID', + 'VERSION', + 'REV', + 'UID', + 'X-ABLABEL', ]; - $collectedNames = []; $stats = [ - "Total vcards" => 0, - "No FN property" => 0, - "Ignored duplicates" => 0, - "Merged values" => 0, - "Error" => 0, - "Unique cards" => 0, - "Total written" => 0, + 'Total vcards' => 0, + 'No FN property' => 0, + 'Ignored duplicates' => 0, + 'Merged values' => 0, + 'Error' => 0, + 'Unique cards' => 0, + 'Total written' => 0, ]; -function writeStats() { - +function writeStats() +{ global $stats; foreach ($stats as $name => $value) { - echo str_pad($name, 23, " ", STR_PAD_RIGHT), str_pad($value, 6, " ", STR_PAD_LEFT), "\n"; + echo str_pad($name, 23, ' ', STR_PAD_RIGHT), str_pad($value, 6, ' ', STR_PAD_LEFT), "\n"; } // Moving cursor back a few lines. - echo "\033[" . count($stats) . "A"; - + echo "\033[".count($stats).'A'; } -function write($vcard) { - +function write($vcard) +{ global $stats, $output; - $stats["Total written"]++; - fwrite($output, $vcard->serialize() . "\n"); - + ++$stats['Total written']; + fwrite($output, $vcard->serialize()."\n"); } while ($vcard = $splitter->getNext()) { - - $stats["Total vcards"]++; + ++$stats['Total vcards']; writeStats(); - $fn = isset($vcard->FN) ? (string)$vcard->FN : null; + $fn = isset($vcard->FN) ? (string) $vcard->FN : null; if (empty($fn)) { - // Immediately write this vcard, we don't compare it. - $stats["No FN property"]++; - $stats['Unique cards']++; + ++$stats['No FN property']; + ++$stats['Unique cards']; write($vcard); $vcard->destroy(); continue; - } if (!isset($collectedNames[$fn])) { - $collectedNames[$fn] = $vcard; - $stats['Unique cards']++; + ++$stats['Unique cards']; continue; - } else { - // Starting comparison for all properties. We only check if properties // in the current vcard exactly appear in the earlier vcard as well. foreach ($vcard->children() as $newProp) { - if (in_array($newProp->name, $ignoredProperties)) { // We don't care about properties such as UID and REV. continue; } $ok = false; foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) { - if ($compareProp->serialize() === $newProp->serialize()) { $ok = true; break; @@ -126,14 +113,11 @@ while ($vcard = $splitter->getNext()) { } if (!$ok) { - - if ($newProp->name === 'EMAIL' || $newProp->name === 'TEL') { - + if ('EMAIL' === $newProp->name || 'TEL' === $newProp->name) { // We're going to make another attempt to find this // property, this time just by value. If we find it, we // consider it a success. foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) { - if ($compareProp->getValue() === $newProp->getValue()) { $ok = true; break; @@ -141,44 +125,36 @@ while ($vcard = $splitter->getNext()) { } if (!$ok) { - // Merging the new value in the old vcard. $collectedNames[$fn]->add(clone $newProp); $ok = true; - $stats['Merged values']++; - + ++$stats['Merged values']; } - } - } if (!$ok) { - // echo $newProp->serialize() . " does not appear in earlier vcard!\n"; - $stats['Error']++; - if ($debug) fwrite($debug, "Missing '" . $newProp->name . "' property in duplicate. Earlier vcard:\n" . $collectedNames[$fn]->serialize() . "\n\nLater:\n" . $vcard->serialize() . "\n\n"); - + ++$stats['Error']; + if ($debug) { + fwrite($debug, "Missing '".$newProp->name."' property in duplicate. Earlier vcard:\n".$collectedNames[$fn]->serialize()."\n\nLater:\n".$vcard->serialize()."\n\n"); + } + $vcard->destroy(); continue 2; } - } - } $vcard->destroy(); - $stats['Ignored duplicates']++; - + ++$stats['Ignored duplicates']; } foreach ($collectedNames as $vcard) { - // Overwriting any old PRODID - $vcard->PRODID = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN'; + $vcard->PRODID = '-//Sabre//Sabre VObject '.Version::VERSION.'//EN'; write($vcard); writeStats(); - } echo str_repeat("\n", count($stats)), "\nDone.\n"; diff --git a/vendor/sabre/vobject/bin/rrulebench.php b/vendor/sabre/vobject/bin/rrulebench.php index af26b4765..583da574c 100644 --- a/vendor/sabre/vobject/bin/rrulebench.php +++ b/vendor/sabre/vobject/bin/rrulebench.php @@ -1,14 +1,14 @@ <?php -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; if ($argc < 4) { - echo "sabre/vobject ", Sabre\VObject\Version::VERSION, " RRULE benchmark\n"; + echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " RRULE benchmark\n"; echo "\n"; echo "This script can be used to measure the speed of the 'recurrence expansion'\n"; - echo "system."; + echo 'system.'; echo "\n"; - echo "Usage: " . $argv[0] . " inputfile.ics startdate enddate\n"; + echo 'Usage: '.$argv[0]." inputfile.ics startdate enddate\n"; die(); } diff --git a/vendor/sabre/vobject/composer.json b/vendor/sabre/vobject/composer.json index 2407cabb1..ad026879e 100644 --- a/vendor/sabre/vobject/composer.json +++ b/vendor/sabre/vobject/composer.json @@ -37,9 +37,7 @@ "sabre/xml" : ">=1.5 <3.0" }, "require-dev" : { - "phpunit/phpunit" : "> 4.8.35, <6.0.0", - "sabre/cs" : "^1.0.0" - + "phpunit/phpunit" : "> 4.8.35, <6.0.0" }, "suggest" : { "hoa/bench" : "If you would like to run the benchmark scripts" diff --git a/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php b/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php index 553912249..fade50e16 100644 --- a/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php +++ b/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php @@ -11,8 +11,8 @@ use Sabre\VObject\Component\VCalendar; * @author Dominik Tobschall (http://tobschall.de/) * @license http://sabre.io/license/ Modified BSD License */ -class BirthdayCalendarGenerator { - +class BirthdayCalendarGenerator +{ /** * Input objects. * @@ -41,12 +41,11 @@ class BirthdayCalendarGenerator { * * @param mixed $objects */ - function __construct($objects = null) { - + public function __construct($objects = null) + { if ($objects) { $this->setObjects($objects); } - } /** @@ -56,52 +55,38 @@ class BirthdayCalendarGenerator { * It's also possible to supply an array of strings or objects. * * @param mixed $objects - * - * @return void */ - function setObjects($objects) { - + public function setObjects($objects) + { if (!is_array($objects)) { $objects = [$objects]; } $this->objects = []; foreach ($objects as $object) { - if (is_string($object)) { - $vObj = Reader::read($object); if (!$vObj instanceof Component\VCard) { throw new \InvalidArgumentException('String could not be parsed as \\Sabre\\VObject\\Component\\VCard by setObjects'); } $this->objects[] = $vObj; - } elseif ($object instanceof Component\VCard) { - $this->objects[] = $object; - } else { - throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component\\VCard arguments to setObjects'); - } - } - } /** - * Sets the output format for the SUMMARY + * Sets the output format for the SUMMARY. * * @param string $format - * - * @return void */ - function setFormat($format) { - + public function setFormat($format) + { $this->format = $format; - } /** @@ -109,12 +94,11 @@ class BirthdayCalendarGenerator { * * @return Component/VCalendar */ - function getResult() { - + public function getResult() + { $calendar = new VCalendar(); foreach ($this->objects as $object) { - // Skip if there is no BDAY property. if (!$object->select('BDAY')) { continue; @@ -152,7 +136,7 @@ class BirthdayCalendarGenerator { $unknownYear = false; if (!$dateParts['year']) { - $object->BDAY = self::DEFAULT_YEAR . '-' . $dateParts['month'] . '-' . $dateParts['date']; + $object->BDAY = self::DEFAULT_YEAR.'-'.$dateParts['month'].'-'.$dateParts['date']; $unknownYear = true; } @@ -161,8 +145,8 @@ class BirthdayCalendarGenerator { $event = $calendar->add('VEVENT', [ 'SUMMARY' => sprintf($this->format, $object->FN->getValue()), 'DTSTART' => new \DateTime($object->BDAY->getValue()), - 'RRULE' => 'FREQ=YEARLY', - 'TRANSP' => 'TRANSPARENT', + 'RRULE' => 'FREQ=YEARLY', + 'TRANSP' => 'TRANSPARENT', ]); // add VALUE=date @@ -172,20 +156,17 @@ class BirthdayCalendarGenerator { if ($unknownYear) { $event->add('X-SABRE-BDAY', 'BDAY', [ 'X-SABRE-VCARD-UID' => $object->UID->getValue(), - 'X-SABRE-VCARD-FN' => $object->FN->getValue(), + 'X-SABRE-VCARD-FN' => $object->FN->getValue(), 'X-SABRE-OMIT-YEAR' => self::DEFAULT_YEAR, ]); } else { $event->add('X-SABRE-BDAY', 'BDAY', [ 'X-SABRE-VCARD-UID' => $object->UID->getValue(), - 'X-SABRE-VCARD-FN' => $object->FN->getValue(), + 'X-SABRE-VCARD-FN' => $object->FN->getValue(), ]); } - } return $calendar; - } - } diff --git a/vendor/sabre/vobject/lib/Cli.php b/vendor/sabre/vobject/lib/Cli.php index df7ac22f3..70b5e8d6e 100644 --- a/vendor/sabre/vobject/lib/Cli.php +++ b/vendor/sabre/vobject/lib/Cli.php @@ -12,8 +12,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Cli { - +class Cli +{ /** * No output. * @@ -96,8 +96,8 @@ class Cli { * * @return int */ - function main(array $argv) { - + public function main(array $argv) + { // @codeCoverageIgnoreStart // We cannot easily test this, so we'll skip it. Pretty basic anyway. @@ -113,103 +113,96 @@ class Cli { // @codeCoverageIgnoreEnd - try { - list($options, $positional) = $this->parseArguments($argv); if (isset($options['q'])) { $this->quiet = true; } - $this->log($this->colorize('green', "sabre/vobject ") . $this->colorize('yellow', Version::VERSION)); + $this->log($this->colorize('green', 'sabre/vobject ').$this->colorize('yellow', Version::VERSION)); foreach ($options as $name => $value) { - switch ($name) { - - case 'q' : + case 'q': // Already handled earlier. break; - case 'h' : - case 'help' : + case 'h': + case 'help': $this->showHelp(); + return 0; break; - case 'format' : + case 'format': switch ($value) { - // jcard/jcal documents - case 'jcard' : - case 'jcal' : + case 'jcard': + case 'jcal': // specific document versions - case 'vcard21' : - case 'vcard30' : - case 'vcard40' : - case 'icalendar20' : + case 'vcard21': + case 'vcard30': + case 'vcard40': + case 'icalendar20': // specific formats - case 'json' : - case 'mimedir' : + case 'json': + case 'mimedir': // icalendar/vcad - case 'icalendar' : - case 'vcard' : + case 'icalendar': + case 'vcard': $this->format = $value; break; - default : - throw new InvalidArgumentException('Unknown format: ' . $value); - + default: + throw new InvalidArgumentException('Unknown format: '.$value); } break; - case 'pretty' : + case 'pretty': if (version_compare(PHP_VERSION, '5.4.0') >= 0) { $this->pretty = true; } break; - case 'forgiving' : + case 'forgiving': $this->forgiving = true; break; - case 'inputformat' : + case 'inputformat': switch ($value) { // json formats - case 'jcard' : - case 'jcal' : - case 'json' : + case 'jcard': + case 'jcal': + case 'json': $this->inputFormat = 'json'; break; // mimedir formats - case 'mimedir' : - case 'icalendar' : - case 'vcard' : - case 'vcard21' : - case 'vcard30' : - case 'vcard40' : - case 'icalendar20' : + case 'mimedir': + case 'icalendar': + case 'vcard': + case 'vcard21': + case 'vcard30': + case 'vcard40': + case 'icalendar20': $this->inputFormat = 'mimedir'; break; - default : - throw new InvalidArgumentException('Unknown format: ' . $value); - + default: + throw new InvalidArgumentException('Unknown format: '.$value); } break; - default : - throw new InvalidArgumentException('Unknown option: ' . $name); - + default: + throw new InvalidArgumentException('Unknown option: '.$name); } - } - if (count($positional) === 0) { + if (0 === count($positional)) { $this->showHelp(); + return 1; } - if (count($positional) === 1) { + if (1 === count($positional)) { throw new InvalidArgumentException('Inputfile is a required argument'); } @@ -218,12 +211,12 @@ class Cli { } if (!in_array($positional[0], ['validate', 'repair', 'convert', 'color'])) { - throw new InvalidArgumentException('Uknown command: ' . $positional[0]); + throw new InvalidArgumentException('Uknown command: '.$positional[0]); } - } catch (InvalidArgumentException $e) { $this->showHelp(); - $this->log('Error: ' . $e->getMessage(), 'red'); + $this->log('Error: '.$e->getMessage(), 'red'); + return 1; } @@ -232,76 +225,71 @@ class Cli { $this->inputPath = $positional[1]; $this->outputPath = isset($positional[2]) ? $positional[2] : '-'; - if ($this->outputPath !== '-') { + if ('-' !== $this->outputPath) { $this->stdout = fopen($this->outputPath, 'w'); } if (!$this->inputFormat) { - if (substr($this->inputPath, -5) === '.json') { + if ('.json' === substr($this->inputPath, -5)) { $this->inputFormat = 'json'; } else { $this->inputFormat = 'mimedir'; } } if (!$this->format) { - if (substr($this->outputPath, -5) === '.json') { + if ('.json' === substr($this->outputPath, -5)) { $this->format = 'json'; } else { $this->format = 'mimedir'; } } - $realCode = 0; try { - while ($input = $this->readInput()) { - $returnCode = $this->$command($input); - if ($returnCode !== 0) $realCode = $returnCode; - + if (0 !== $returnCode) { + $realCode = $returnCode; + } } - } catch (EofException $e) { // end of file } catch (\Exception $e) { - $this->log('Error: ' . $e->getMessage(), 'red'); + $this->log('Error: '.$e->getMessage(), 'red'); + return 2; } return $realCode; - } /** * Shows the help message. - * - * @return void */ - protected function showHelp() { - + protected function showHelp() + { $this->log('Usage:', 'yellow'); - $this->log(" vobject [options] command [arguments]"); + $this->log(' vobject [options] command [arguments]'); $this->log(''); $this->log('Options:', 'yellow'); - $this->log($this->colorize('green', ' -q ') . "Don't output anything."); - $this->log($this->colorize('green', ' -help -h ') . "Display this help message."); - $this->log($this->colorize('green', ' --format ') . "Convert to a specific format. Must be one of: vcard, vcard21,"); - $this->log($this->colorize('green', ' --forgiving ') . "Makes the parser less strict."); - $this->log(" vcard30, vcard40, icalendar20, jcal, jcard, json, mimedir."); - $this->log($this->colorize('green', ' --inputformat ') . "If the input format cannot be guessed from the extension, it"); - $this->log(" must be specified here."); + $this->log($this->colorize('green', ' -q ')."Don't output anything."); + $this->log($this->colorize('green', ' -help -h ').'Display this help message.'); + $this->log($this->colorize('green', ' --format ').'Convert to a specific format. Must be one of: vcard, vcard21,'); + $this->log($this->colorize('green', ' --forgiving ').'Makes the parser less strict.'); + $this->log(' vcard30, vcard40, icalendar20, jcal, jcard, json, mimedir.'); + $this->log($this->colorize('green', ' --inputformat ').'If the input format cannot be guessed from the extension, it'); + $this->log(' must be specified here.'); // Only PHP 5.4 and up if (version_compare(PHP_VERSION, '5.4.0') >= 0) { - $this->log($this->colorize('green', ' --pretty ') . "json pretty-print."); + $this->log($this->colorize('green', ' --pretty ').'json pretty-print.'); } $this->log(''); $this->log('Commands:', 'yellow'); - $this->log($this->colorize('green', ' validate') . ' source_file Validates a file for correctness.'); - $this->log($this->colorize('green', ' repair') . ' source_file [output_file] Repairs a file.'); - $this->log($this->colorize('green', ' convert') . ' source_file [output_file] Converts a file.'); - $this->log($this->colorize('green', ' color') . ' source_file Colorize a file, useful for debbugging.'); + $this->log($this->colorize('green', ' validate').' source_file Validates a file for correctness.'); + $this->log($this->colorize('green', ' repair').' source_file [output_file] Repairs a file.'); + $this->log($this->colorize('green', ' convert').' source_file [output_file] Converts a file.'); + $this->log($this->colorize('green', ' color').' source_file Colorize a file, useful for debbugging.'); $this->log( <<<HELP @@ -319,7 +307,6 @@ HELP $this->log(' vobject color calendar.ics'); $this->log(''); $this->log('https://github.com/fruux/sabre-vobject', 'purple'); - } /** @@ -329,24 +316,23 @@ HELP * * @return int */ - protected function validate(Component $vObj) { - + protected function validate(Component $vObj) + { $returnCode = 0; switch ($vObj->name) { - case 'VCALENDAR' : - $this->log("iCalendar: " . (string)$vObj->VERSION); + case 'VCALENDAR': + $this->log('iCalendar: '.(string) $vObj->VERSION); break; - case 'VCARD' : - $this->log("vCard: " . (string)$vObj->VERSION); + case 'VCARD': + $this->log('vCard: '.(string) $vObj->VERSION); break; } $warnings = $vObj->validate(); if (!count($warnings)) { - $this->log(" No warnings!"); + $this->log(' No warnings!'); } else { - $levels = [ 1 => 'REPAIRED', 2 => 'WARNING', @@ -354,19 +340,15 @@ HELP ]; $returnCode = 2; foreach ($warnings as $warn) { - $extra = ''; if ($warn['node'] instanceof Property) { - $extra = ' (property: "' . $warn['node']->name . '")'; + $extra = ' (property: "'.$warn['node']->name.'")'; } - $this->log(" [" . $levels[$warn['level']] . '] ' . $warn['message'] . $extra); - + $this->log(' ['.$levels[$warn['level']].'] '.$warn['message'].$extra); } - } return $returnCode; - } /** @@ -376,24 +358,23 @@ HELP * * @return int */ - protected function repair(Component $vObj) { - + protected function repair(Component $vObj) + { $returnCode = 0; switch ($vObj->name) { - case 'VCALENDAR' : - $this->log("iCalendar: " . (string)$vObj->VERSION); + case 'VCALENDAR': + $this->log('iCalendar: '.(string) $vObj->VERSION); break; - case 'VCARD' : - $this->log("vCard: " . (string)$vObj->VERSION); + case 'VCARD': + $this->log('vCard: '.(string) $vObj->VERSION); break; } $warnings = $vObj->validate(Node::REPAIR); if (!count($warnings)) { - $this->log(" No warnings!"); + $this->log(' No warnings!'); } else { - $levels = [ 1 => 'REPAIRED', 2 => 'WARNING', @@ -401,20 +382,16 @@ HELP ]; $returnCode = 2; foreach ($warnings as $warn) { - $extra = ''; if ($warn['node'] instanceof Property) { - $extra = ' (property: "' . $warn['node']->name . '")'; + $extra = ' (property: "'.$warn['node']->name.'")'; } - $this->log(" [" . $levels[$warn['level']] . '] ' . $warn['message'] . $extra); - + $this->log(' ['.$levels[$warn['level']].'] '.$warn['message'].$extra); } - } fwrite($this->stdout, $vObj->serialize()); return $returnCode; - } /** @@ -424,47 +401,46 @@ HELP * * @return int */ - protected function convert($vObj) { - + protected function convert($vObj) + { $json = false; $convertVersion = null; $forceInput = null; switch ($this->format) { - case 'json' : + case 'json': $json = true; - if ($vObj->name === 'VCARD') { + if ('VCARD' === $vObj->name) { $convertVersion = Document::VCARD40; } break; - case 'jcard' : + case 'jcard': $json = true; $forceInput = 'VCARD'; $convertVersion = Document::VCARD40; break; - case 'jcal' : + case 'jcal': $json = true; $forceInput = 'VCALENDAR'; break; - case 'mimedir' : - case 'icalendar' : - case 'icalendar20' : - case 'vcard' : + case 'mimedir': + case 'icalendar': + case 'icalendar20': + case 'vcard': break; - case 'vcard21' : + case 'vcard21': $convertVersion = Document::VCARD21; break; - case 'vcard30' : + case 'vcard30': $convertVersion = Document::VCARD30; break; - case 'vcard40' : + case 'vcard40': $convertVersion = Document::VCARD40; break; - } if ($forceInput && $vObj->name !== $forceInput) { - throw new \Exception('You cannot convert a ' . strtolower($vObj->name) . ' to ' . $this->format); + throw new \Exception('You cannot convert a '.strtolower($vObj->name).' to '.$this->format); } if ($convertVersion) { $vObj = $vObj->convert($convertVersion); @@ -480,7 +456,6 @@ HELP } return 0; - } /** @@ -490,10 +465,9 @@ HELP * * @return int */ - protected function color($vObj) { - + protected function color($vObj) + { fwrite($this->stdout, $this->serializeComponent($vObj)); - } /** @@ -503,19 +477,19 @@ HELP * * @return string */ - protected function colorize($color, $str, $resetTo = 'default') { - + protected function colorize($color, $str, $resetTo = 'default') + { $colors = [ - 'cyan' => '1;36', - 'red' => '1;31', - 'yellow' => '1;33', - 'blue' => '0;34', - 'green' => '0;32', + 'cyan' => '1;36', + 'red' => '1;31', + 'yellow' => '1;33', + 'blue' => '0;34', + 'green' => '0;32', 'default' => '0', - 'purple' => '0;35', + 'purple' => '0;35', ]; - return "\033[" . $colors[$color] . 'm' . $str . "\033[" . $colors[$resetTo] . "m"; + return "\033[".$colors[$color].'m'.$str."\033[".$colors[$resetTo].'m'; } /** @@ -523,20 +497,17 @@ HELP * * @param string $color * @param string $str - * - * @return void */ - protected function cWrite($color, $str) { - + protected function cWrite($color, $str) + { fwrite($this->stdout, $this->colorize($color, $str)); - } - protected function serializeComponent(Component $vObj) { - + protected function serializeComponent(Component $vObj) + { $this->cWrite('cyan', 'BEGIN'); $this->cWrite('red', ':'); - $this->cWrite('yellow', $vObj->name . "\n"); + $this->cWrite('yellow', $vObj->name."\n"); /** * Gives a component a 'score' for sorting purposes. @@ -548,52 +519,51 @@ HELP * space to accomodate elements. The $key is added to the $score to * preserve the original relative order of elements. * - * @param int $key + * @param int $key * @param array $array * * @return int */ - $sortScore = function($key, $array) { - + $sortScore = function ($key, $array) { if ($array[$key] instanceof Component) { - // We want to encode VTIMEZONE first, this is a personal // preference. - if ($array[$key]->name === 'VTIMEZONE') { + if ('VTIMEZONE' === $array[$key]->name) { $score = 300000000; + return $score + $key; } else { $score = 400000000; + return $score + $key; } } else { // Properties get encoded first // VCARD version 4.0 wants the VERSION property to appear first if ($array[$key] instanceof Property) { - if ($array[$key]->name === 'VERSION') { + if ('VERSION' === $array[$key]->name) { $score = 100000000; + return $score + $key; } else { // All other properties $score = 200000000; + return $score + $key; } } } - }; $children = $vObj->children(); $tmp = $children; uksort( $children, - function($a, $b) use ($sortScore, $tmp) { - + function ($a, $b) use ($sortScore, $tmp) { $sA = $sortScore($a, $tmp); $sB = $sortScore($b, $tmp); return $sA - $sB; - } ); @@ -607,19 +577,16 @@ HELP $this->cWrite('cyan', 'END'); $this->cWrite('red', ':'); - $this->cWrite('yellow', $vObj->name . "\n"); - + $this->cWrite('yellow', $vObj->name."\n"); } /** * Colorizes a property. * * @param Property $property - * - * @return void */ - protected function serializeProperty(Property $property) { - + protected function serializeProperty(Property $property) + { if ($property->group) { $this->cWrite('default', $property->group); $this->cWrite('red', '.'); @@ -628,19 +595,14 @@ HELP $this->cWrite('yellow', $property->name); foreach ($property->parameters as $param) { - $this->cWrite('red', ';'); $this->cWrite('blue', $param->serialize()); - } $this->cWrite('red', ':'); if ($property instanceof Property\Binary) { - - $this->cWrite('default', 'embedded binary stripped. (' . strlen($property->getValue()) . ' bytes)'); - + $this->cWrite('default', 'embedded binary stripped. ('.strlen($property->getValue()).' bytes)'); } else { - $parts = $property->getParts(); $first1 = true; // Looping through property values @@ -652,7 +614,7 @@ HELP } $first2 = true; // Looping through property sub-values - foreach ((array)$part as $subPart) { + foreach ((array) $part as $subPart) { if ($first2) { $first2 = false; } else { @@ -664,42 +626,39 @@ HELP $subPart, [ '\\' => $this->colorize('purple', '\\\\', 'green'), - ';' => $this->colorize('purple', '\;', 'green'), - ',' => $this->colorize('purple', '\,', 'green'), + ';' => $this->colorize('purple', '\;', 'green'), + ',' => $this->colorize('purple', '\,', 'green'), "\n" => $this->colorize('purple', "\\n\n\t", 'green'), - "\r" => "", + "\r" => '', ] ); $this->cWrite('green', $subPart); } } - } - $this->cWrite("default", "\n"); - + $this->cWrite('default', "\n"); } /** * Parses the list of arguments. * * @param array $argv - * - * @return void */ - protected function parseArguments(array $argv) { - + protected function parseArguments(array $argv) + { $positional = []; $options = []; - for ($ii = 0; $ii < count($argv); $ii++) { - + for ($ii = 0; $ii < count($argv); ++$ii) { // Skipping the first argument. - if ($ii === 0) continue; + if (0 === $ii) { + continue; + } $v = $argv[$ii]; - if (substr($v, 0, 2) === '--') { + if ('--' === substr($v, 0, 2)) { // This is a long-form option. $optionName = substr($v, 2); $optionValue = true; @@ -707,22 +666,17 @@ HELP list($optionName, $optionValue) = explode('=', $optionName); } $options[$optionName] = $optionValue; - } elseif (substr($v, 0, 1) === '-' && strlen($v) > 1) { + } elseif ('-' === substr($v, 0, 1) && strlen($v) > 1) { // This is a short-form option. foreach (str_split(substr($v, 1)) as $option) { $options[$option] = true; } - } else { - $positional[] = $v; - } - } return [$options, $positional]; - } protected $parser; @@ -732,14 +686,14 @@ HELP * * @return Component */ - protected function readInput() { - + protected function readInput() + { if (!$this->parser) { - if ($this->inputPath !== '-') { + if ('-' !== $this->inputPath) { $this->stdin = fopen($this->inputPath, 'r'); } - if ($this->inputFormat === 'mimedir') { + if ('mimedir' === $this->inputFormat) { $this->parser = new Parser\MimeDir($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0)); } else { $this->parser = new Parser\Json($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0)); @@ -747,25 +701,20 @@ HELP } return $this->parser->parse(); - } /** * Sends a message to STDERR. * * @param string $msg - * - * @return void */ - protected function log($msg, $color = 'default') { - + protected function log($msg, $color = 'default') + { if (!$this->quiet) { - if ($color !== 'default') { + if ('default' !== $color) { $msg = $this->colorize($color, $msg); } - fwrite($this->stderr, $msg . "\n"); + fwrite($this->stderr, $msg."\n"); } - } - } diff --git a/vendor/sabre/vobject/lib/Component.php b/vendor/sabre/vobject/lib/Component.php index ac87a10ec..a33b7d577 100644 --- a/vendor/sabre/vobject/lib/Component.php +++ b/vendor/sabre/vobject/lib/Component.php @@ -14,8 +14,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Component extends Node { - +class Component extends Node +{ /** * Component name. * @@ -44,14 +44,12 @@ class Component extends Node { * ensure that this does not happen, set $defaults to false. * * @param Document $root - * @param string $name such as VCALENDAR, VEVENT. - * @param array $children - * @param bool $defaults - * - * @return void + * @param string $name such as VCALENDAR, VEVENT + * @param array $children + * @param bool $defaults */ - function __construct(Document $root, $name, array $children = [], $defaults = true) { - + public function __construct(Document $root, $name, array $children = [], $defaults = true) + { $this->name = strtoupper($name); $this->root = $root; @@ -84,13 +82,11 @@ class Component extends Node { // Component or Property $this->add($child); } else { - // Property key=>value $this->add($k, $child); } } } - } /** @@ -106,8 +102,8 @@ class Component extends Node { * * @return Node */ - function add() { - + public function add() + { $arguments = func_get_args(); if ($arguments[0] instanceof Node) { @@ -116,15 +112,10 @@ class Component extends Node { } $arguments[0]->parent = $this; $newNode = $arguments[0]; - } elseif (is_string($arguments[0])) { - $newNode = call_user_func_array([$this->root, 'create'], $arguments); - } else { - throw new \InvalidArgumentException('The first argument must either be a \\Sabre\\VObject\\Node or a string'); - } $name = $newNode->name; @@ -133,8 +124,8 @@ class Component extends Node { } else { $this->children[$name] = [$newNode]; } - return $newNode; + return $newNode; } /** @@ -146,36 +137,34 @@ class Component extends Node { * exact item will be removed. * * @param string|Property|Component $item - * @return void */ - function remove($item) { - + public function remove($item) + { if (is_string($item)) { // If there's no dot in the name, it's an exact property name and // we can just wipe out all those properties. // - if (strpos($item, '.') === false) { + if (false === strpos($item, '.')) { unset($this->children[strtoupper($item)]); + return; } // If there was a dot, we need to ask select() to help us out and // then we just call remove recursively. foreach ($this->select($item) as $child) { - $this->remove($child); - } } else { foreach ($this->select($item->name) as $k => $child) { if ($child === $item) { unset($this->children[$item->name][$k]); + return; } } } throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component'); - } /** @@ -184,14 +173,14 @@ class Component extends Node { * * @return array */ - function children() { - + public function children() + { $result = []; foreach ($this->children as $childGroup) { $result = array_merge($result, $childGroup); } - return $result; + return $result; } /** @@ -200,8 +189,8 @@ class Component extends Node { * * @return array */ - function getComponents() { - + public function getComponents() + { $result = []; foreach ($this->children as $childGroup) { @@ -211,8 +200,8 @@ class Component extends Node { } } } - return $result; + return $result; } /** @@ -226,19 +215,21 @@ class Component extends Node { * has not been assigned a group, specify ".EMAIL". * * @param string $name + * * @return array */ - function select($name) { - + public function select($name) + { $group = null; $name = strtoupper($name); - if (strpos($name, '.') !== false) { + if (false !== strpos($name, '.')) { list($group, $name) = explode('.', $name, 2); } - if ($name === '') $name = null; + if ('' === $name) { + $name = null; + } if (!is_null($name)) { - $result = isset($this->children[$name]) ? $this->children[$name] : []; if (is_null($group)) { @@ -248,32 +239,25 @@ class Component extends Node { // more. return array_filter( $result, - function($child) use ($group) { - + function ($child) use ($group) { return $child instanceof Property && strtoupper($child->group) === $group; - } ); } - } // If we got to this point, it means there was no 'name' specified for // searching, implying that this is a group-only search. $result = []; foreach ($this->children as $childGroup) { - foreach ($childGroup as $child) { - if ($child instanceof Property && strtoupper($child->group) === $group) { $result[] = $child; } - } - } - return $result; + return $result; } /** @@ -281,9 +265,9 @@ class Component extends Node { * * @return string */ - function serialize() { - - $str = "BEGIN:" . $this->name . "\r\n"; + public function serialize() + { + $str = 'BEGIN:'.$this->name."\r\n"; /** * Gives a component a 'score' for sorting purposes. @@ -295,60 +279,60 @@ class Component extends Node { * space to accomodate elements. The $key is added to the $score to * preserve the original relative order of elements. * - * @param int $key + * @param int $key * @param array $array * * @return int */ - $sortScore = function($key, $array) { - + $sortScore = function ($key, $array) { if ($array[$key] instanceof Component) { - // We want to encode VTIMEZONE first, this is a personal // preference. - if ($array[$key]->name === 'VTIMEZONE') { + if ('VTIMEZONE' === $array[$key]->name) { $score = 300000000; + return $score + $key; } else { $score = 400000000; + return $score + $key; } } else { // Properties get encoded first // VCARD version 4.0 wants the VERSION property to appear first if ($array[$key] instanceof Property) { - if ($array[$key]->name === 'VERSION') { + if ('VERSION' === $array[$key]->name) { $score = 100000000; + return $score + $key; } else { // All other properties $score = 200000000; + return $score + $key; } } } - }; $children = $this->children(); $tmp = $children; uksort( $children, - function($a, $b) use ($sortScore, $tmp) { - + function ($a, $b) use ($sortScore, $tmp) { $sA = $sortScore($a, $tmp); $sB = $sortScore($b, $tmp); return $sA - $sB; - } ); - foreach ($children as $child) $str .= $child->serialize(); - $str .= "END:" . $this->name . "\r\n"; + foreach ($children as $child) { + $str .= $child->serialize(); + } + $str .= 'END:'.$this->name."\r\n"; return $str; - } /** @@ -357,8 +341,8 @@ class Component extends Node { * * @return array */ - function jsonSerialize() { - + public function jsonSerialize() + { $components = []; $properties = []; @@ -375,21 +359,18 @@ class Component extends Node { return [ strtolower($this->name), $properties, - $components + $components, ]; - } /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - function xmlSerialize(Xml\Writer $writer) { - + public function xmlSerialize(Xml\Writer $writer) + { $components = []; $properties = []; @@ -406,7 +387,6 @@ class Component extends Node { $writer->startElement(strtolower($this->name)); if (!empty($properties)) { - $writer->startElement('properties'); foreach ($properties as $property) { @@ -414,11 +394,9 @@ class Component extends Node { } $writer->endElement(); - } if (!empty($components)) { - $writer->startElement('components'); foreach ($components as $component) { @@ -429,7 +407,6 @@ class Component extends Node { } $writer->endElement(); - } /** @@ -437,10 +414,9 @@ class Component extends Node { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return []; - } /* Magic property accessors {{{ */ @@ -459,24 +435,22 @@ class Component extends Node { * * @return Property */ - function __get($name) { - - if ($name === 'children') { - + public function __get($name) + { + if ('children' === $name) { throw new \RuntimeException('Starting sabre/vobject 4.0 the children property is now protected. You should use the children() method instead'); - } $matches = $this->select($name); - if (count($matches) === 0) { + if (0 === count($matches)) { return; } else { $firstMatch = current($matches); - /** @var $firstMatch Property */ + /* @var $firstMatch Property */ $firstMatch->setIterator(new ElementList(array_values($matches))); + return $firstMatch; } - } /** @@ -486,11 +460,11 @@ class Component extends Node { * * @return bool */ - function __isset($name) { - + public function __isset($name) + { $matches = $this->select($name); - return count($matches) > 0; + return count($matches) > 0; } /** @@ -503,12 +477,10 @@ class Component extends Node { * a new item with the same name, always use the add() method. * * @param string $name - * @param mixed $value - * - * @return void + * @param mixed $value */ - function __set($name, $value) { - + public function __set($name, $value) + { $name = strtoupper($name); $this->remove($name); if ($value instanceof self || $value instanceof Property) { @@ -523,13 +495,10 @@ class Component extends Node { * specified name. * * @param string $name - * - * @return void */ - function __unset($name) { - + public function __unset($name) + { $this->remove($name); - } /* }}} */ @@ -537,11 +506,9 @@ class Component extends Node { /** * This method is automatically called when the object is cloned. * Specifically, this will ensure all child elements are also cloned. - * - * @return void */ - function __clone() { - + public function __clone() + { foreach ($this->children as $childName => $childGroup) { foreach ($childGroup as $key => $child) { $clonedChild = clone $child; @@ -550,7 +517,6 @@ class Component extends Node { $this->children[$childName][$key] = $clonedChild; } } - } /** @@ -574,10 +540,9 @@ class Component extends Node { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return []; - } /** @@ -604,8 +569,8 @@ class Component extends Node { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $rules = $this->getValidationRules(); $defaults = $this->getDefaults(); @@ -618,49 +583,48 @@ class Component extends Node { if (!isset($propertyCounters[$name])) { $propertyCounters[$name] = 1; } else { - $propertyCounters[$name]++; + ++$propertyCounters[$name]; } $messages = array_merge($messages, $child->validate($options)); } foreach ($rules as $propName => $rule) { - switch ($rule) { - case '0' : + case '0': if (isset($propertyCounters[$propName])) { $messages[] = [ - 'level' => 3, - 'message' => $propName . ' MUST NOT appear in a ' . $this->name . ' component', - 'node' => $this, + 'level' => 3, + 'message' => $propName.' MUST NOT appear in a '.$this->name.' component', + 'node' => $this, ]; } break; - case '1' : - if (!isset($propertyCounters[$propName]) || $propertyCounters[$propName] !== 1) { + case '1': + if (!isset($propertyCounters[$propName]) || 1 !== $propertyCounters[$propName]) { $repaired = false; if ($options & self::REPAIR && isset($defaults[$propName])) { $this->add($propName, $defaults[$propName]); $repaired = true; } $messages[] = [ - 'level' => $repaired ? 1 : 3, - 'message' => $propName . ' MUST appear exactly once in a ' . $this->name . ' component', - 'node' => $this, + 'level' => $repaired ? 1 : 3, + 'message' => $propName.' MUST appear exactly once in a '.$this->name.' component', + 'node' => $this, ]; } break; - case '+' : + case '+': if (!isset($propertyCounters[$propName]) || $propertyCounters[$propName] < 1) { $messages[] = [ - 'level' => 3, - 'message' => $propName . ' MUST appear at least once in a ' . $this->name . ' component', - 'node' => $this, + 'level' => 3, + 'message' => $propName.' MUST appear at least once in a '.$this->name.' component', + 'node' => $this, ]; } break; - case '*' : + case '*': break; - case '?' : + case '?': if (isset($propertyCounters[$propName]) && $propertyCounters[$propName] > 1) { $level = 3; @@ -669,7 +633,7 @@ class Component extends Node { if ($options & self::REPAIR) { $properties = array_unique($this->select($propName), SORT_REGULAR); - if (count($properties) === 1) { + if (1 === count($properties)) { $this->remove($propName); $this->add($properties[0]); @@ -678,18 +642,16 @@ class Component extends Node { } $messages[] = [ - 'level' => $level, - 'message' => $propName . ' MUST NOT appear more than once in a ' . $this->name . ' component', - 'node' => $this, + 'level' => $level, + 'message' => $propName.' MUST NOT appear more than once in a '.$this->name.' component', + 'node' => $this, ]; } break; - } - } - return $messages; + return $messages; } /** @@ -697,11 +659,9 @@ class Component extends Node { * * It's intended to remove all circular references, so PHP can easily clean * it up. - * - * @return void */ - function destroy() { - + public function destroy() + { parent::destroy(); foreach ($this->children as $childGroup) { foreach ($childGroup as $child) { @@ -709,7 +669,5 @@ class Component extends Node { } } $this->children = []; - } - } diff --git a/vendor/sabre/vobject/lib/Component/Available.php b/vendor/sabre/vobject/lib/Component/Available.php index b3aaf08af..5510b9e0a 100644 --- a/vendor/sabre/vobject/lib/Component/Available.php +++ b/vendor/sabre/vobject/lib/Component/Available.php @@ -14,8 +14,8 @@ use Sabre\VObject; * @author Ivan Enderlin * @license http://sabre.io/license/ Modified BSD License */ -class Available extends VObject\Component { - +class Available extends VObject\Component +{ /** * Returns the 'effective start' and 'effective end' of this VAVAILABILITY * component. @@ -28,8 +28,8 @@ class Available extends VObject\Component { * * @return array */ - function getEffectiveStartEnd() { - + public function getEffectiveStartEnd() + { $effectiveStart = $this->DTSTART->getDateTime(); if (isset($this->DTEND)) { $effectiveEnd = $this->DTEND->getDateTime(); @@ -38,7 +38,6 @@ class Available extends VObject\Component { } return [$effectiveStart, $effectiveEnd]; - } /** @@ -56,32 +55,31 @@ class Available extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'UID' => 1, + 'UID' => 1, 'DTSTART' => 1, 'DTSTAMP' => 1, - 'DTEND' => '?', + 'DTEND' => '?', 'DURATION' => '?', - 'CREATED' => '?', - 'DESCRIPTION' => '?', + 'CREATED' => '?', + 'DESCRIPTION' => '?', 'LAST-MODIFIED' => '?', 'RECURRENCE-ID' => '?', - 'RRULE' => '?', - 'SUMMARY' => '?', + 'RRULE' => '?', + 'SUMMARY' => '?', 'CATEGORIES' => '*', - 'COMMENT' => '*', - 'CONTACT' => '*', - 'EXDATE' => '*', - 'RDATE' => '*', + 'COMMENT' => '*', + 'CONTACT' => '*', + 'EXDATE' => '*', + 'RDATE' => '*', 'AVAILABLE' => '*', ]; - } /** @@ -108,19 +106,18 @@ class Available extends VObject\Component { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $result = parent::validate($options); if (isset($this->DTEND) && isset($this->DURATION)) { $result[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'DTEND and DURATION cannot both be present', - 'node' => $this + 'node' => $this, ]; } return $result; - } } diff --git a/vendor/sabre/vobject/lib/Component/VAlarm.php b/vendor/sabre/vobject/lib/Component/VAlarm.php index faa8a5e74..bd00eb600 100644 --- a/vendor/sabre/vobject/lib/Component/VAlarm.php +++ b/vendor/sabre/vobject/lib/Component/VAlarm.php @@ -16,8 +16,8 @@ use Sabre\VObject\InvalidDataException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VAlarm extends VObject\Component { - +class VAlarm extends VObject\Component +{ /** * Returns a DateTime object when this alarm is going to trigger. * @@ -25,17 +25,16 @@ class VAlarm extends VObject\Component { * * @return DateTimeImmutable */ - function getEffectiveTriggerTime() { - + public function getEffectiveTriggerTime() + { $trigger = $this->TRIGGER; - if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') { + if (!isset($trigger['VALUE']) || 'DURATION' === strtoupper($trigger['VALUE'])) { $triggerDuration = VObject\DateTimeParser::parseDuration($this->TRIGGER); - $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START'; + $related = (isset($trigger['RELATED']) && 'END' == strtoupper($trigger['RELATED'])) ? 'END' : 'START'; $parentComponent = $this->parent; - if ($related === 'START') { - - if ($parentComponent->name === 'VTODO') { + if ('START' === $related) { + if ('VTODO' === $parentComponent->name) { $propName = 'DUE'; } else { $propName = 'DTSTART'; @@ -44,9 +43,9 @@ class VAlarm extends VObject\Component { $effectiveTrigger = $parentComponent->$propName->getDateTime(); $effectiveTrigger = $effectiveTrigger->add($triggerDuration); } else { - if ($parentComponent->name === 'VTODO') { + if ('VTODO' === $parentComponent->name) { $endProp = 'DUE'; - } elseif ($parentComponent->name === 'VEVENT') { + } elseif ('VEVENT' === $parentComponent->name) { $endProp = 'DTEND'; } else { throw new InvalidDataException('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT'); @@ -68,8 +67,8 @@ class VAlarm extends VObject\Component { } else { $effectiveTrigger = $trigger->getDateTime(); } - return $effectiveTrigger; + return $effectiveTrigger; } /** @@ -84,30 +83,29 @@ class VAlarm extends VObject\Component { * * @return bool */ - function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) { - + public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) + { $effectiveTrigger = $this->getEffectiveTriggerTime(); if (isset($this->DURATION)) { $duration = VObject\DateTimeParser::parseDuration($this->DURATION); - $repeat = (string)$this->REPEAT; + $repeat = (string) $this->REPEAT; if (!$repeat) { $repeat = 1; } - $period = new \DatePeriod($effectiveTrigger, $duration, (int)$repeat); + $period = new \DatePeriod($effectiveTrigger, $duration, (int) $repeat); foreach ($period as $occurrence) { - if ($start <= $occurrence && $end > $occurrence) { return true; } } + return false; } else { - return ($start <= $effectiveTrigger && $end > $effectiveTrigger); + return $start <= $effectiveTrigger && $end > $effectiveTrigger; } - } /** @@ -125,18 +123,16 @@ class VAlarm extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'ACTION' => 1, + 'ACTION' => 1, 'TRIGGER' => 1, 'DURATION' => '?', - 'REPEAT' => '?', + 'REPEAT' => '?', 'ATTACH' => '?', ]; - } - } diff --git a/vendor/sabre/vobject/lib/Component/VAvailability.php b/vendor/sabre/vobject/lib/Component/VAvailability.php index 66b3310c5..6f3e7f13c 100644 --- a/vendor/sabre/vobject/lib/Component/VAvailability.php +++ b/vendor/sabre/vobject/lib/Component/VAvailability.php @@ -15,8 +15,8 @@ use Sabre\VObject; * @author Ivan Enderlin * @license http://sabre.io/license/ Modified BSD License */ -class VAvailability extends VObject\Component { - +class VAvailability extends VObject\Component +{ /** * Returns true or false depending on if the event falls in the specified * time-range. This is used for filtering purposes. @@ -31,14 +31,14 @@ class VAvailability extends VObject\Component { * * @return bool */ - function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) { - + public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) + { list($effectiveStart, $effectiveEnd) = $this->getEffectiveStartEnd(); - return ( + + return (is_null($effectiveStart) || $start < $effectiveEnd) && (is_null($effectiveEnd) || $end > $effectiveStart) - ); - + ; } /** @@ -53,8 +53,8 @@ class VAvailability extends VObject\Component { * * @return array */ - function getEffectiveStartEnd() { - + public function getEffectiveStartEnd() + { $effectiveStart = null; $effectiveEnd = null; @@ -68,10 +68,8 @@ class VAvailability extends VObject\Component { } return [$effectiveStart, $effectiveEnd]; - } - /** * A simple list of validation rules. * @@ -87,31 +85,30 @@ class VAvailability extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'UID' => 1, + 'UID' => 1, 'DTSTAMP' => 1, - 'BUSYTYPE' => '?', - 'CLASS' => '?', - 'CREATED' => '?', - 'DESCRIPTION' => '?', - 'DTSTART' => '?', + 'BUSYTYPE' => '?', + 'CLASS' => '?', + 'CREATED' => '?', + 'DESCRIPTION' => '?', + 'DTSTART' => '?', 'LAST-MODIFIED' => '?', - 'ORGANIZER' => '?', - 'PRIORITY' => '?', - 'SEQUENCE' => '?', - 'SUMMARY' => '?', - 'URL' => '?', - 'DTEND' => '?', - 'DURATION' => '?', + 'ORGANIZER' => '?', + 'PRIORITY' => '?', + 'SEQUENCE' => '?', + 'SUMMARY' => '?', + 'URL' => '?', + 'DTEND' => '?', + 'DURATION' => '?', 'CATEGORIES' => '*', - 'COMMENT' => '*', - 'CONTACT' => '*', + 'COMMENT' => '*', + 'CONTACT' => '*', ]; - } /** @@ -138,19 +135,18 @@ class VAvailability extends VObject\Component { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $result = parent::validate($options); if (isset($this->DTEND) && isset($this->DURATION)) { $result[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'DTEND and DURATION cannot both be present', - 'node' => $this + 'node' => $this, ]; } return $result; - } } diff --git a/vendor/sabre/vobject/lib/Component/VCalendar.php b/vendor/sabre/vobject/lib/Component/VCalendar.php index 1b3137d38..4687a092b 100644 --- a/vendor/sabre/vobject/lib/Component/VCalendar.php +++ b/vendor/sabre/vobject/lib/Component/VCalendar.php @@ -20,8 +20,8 @@ use Sabre\VObject\Recur\NoInstancesException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VCalendar extends VObject\Document { - +class VCalendar extends VObject\Document +{ /** * The default name for this component. * @@ -29,23 +29,23 @@ class VCalendar extends VObject\Document { * * @var string */ - static $defaultName = 'VCALENDAR'; + public static $defaultName = 'VCALENDAR'; /** * This is a list of components, and which classes they should map to. * * @var array */ - static $componentMap = [ - 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar', - 'VALARM' => 'Sabre\\VObject\\Component\\VAlarm', - 'VEVENT' => 'Sabre\\VObject\\Component\\VEvent', - 'VFREEBUSY' => 'Sabre\\VObject\\Component\\VFreeBusy', + public static $componentMap = [ + 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar', + 'VALARM' => 'Sabre\\VObject\\Component\\VAlarm', + 'VEVENT' => 'Sabre\\VObject\\Component\\VEvent', + 'VFREEBUSY' => 'Sabre\\VObject\\Component\\VFreeBusy', 'VAVAILABILITY' => 'Sabre\\VObject\\Component\\VAvailability', - 'AVAILABLE' => 'Sabre\\VObject\\Component\\Available', - 'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal', - 'VTIMEZONE' => 'Sabre\\VObject\\Component\\VTimeZone', - 'VTODO' => 'Sabre\\VObject\\Component\\VTodo', + 'AVAILABLE' => 'Sabre\\VObject\\Component\\Available', + 'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal', + 'VTIMEZONE' => 'Sabre\\VObject\\Component\\VTimeZone', + 'VTODO' => 'Sabre\\VObject\\Component\\VTodo', ]; /** @@ -53,22 +53,22 @@ class VCalendar extends VObject\Document { * * @var array */ - static $valueMap = [ - 'BINARY' => 'Sabre\\VObject\\Property\\Binary', - 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', + public static $valueMap = [ + 'BINARY' => 'Sabre\\VObject\\Property\\Binary', + 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', 'CAL-ADDRESS' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', - 'DATE' => 'Sabre\\VObject\\Property\\ICalendar\\Date', - 'DATE-TIME' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', - 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', - 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', - 'PERIOD' => 'Sabre\\VObject\\Property\\ICalendar\\Period', - 'RECUR' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', - 'TEXT' => 'Sabre\\VObject\\Property\\Text', - 'TIME' => 'Sabre\\VObject\\Property\\Time', - 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. - 'URI' => 'Sabre\\VObject\\Property\\Uri', - 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', + 'DATE' => 'Sabre\\VObject\\Property\\ICalendar\\Date', + 'DATE-TIME' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', + 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', + 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', + 'PERIOD' => 'Sabre\\VObject\\Property\\ICalendar\\Period', + 'RECUR' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', + 'TEXT' => 'Sabre\\VObject\\Property\\Text', + 'TIME' => 'Sabre\\VObject\\Property\\Time', + 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. + 'URI' => 'Sabre\\VObject\\Property\\Uri', + 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', ]; /** @@ -76,81 +76,80 @@ class VCalendar extends VObject\Document { * * @var array */ - static $propertyMap = [ + public static $propertyMap = [ // Calendar properties 'CALSCALE' => 'Sabre\\VObject\\Property\\FlatText', - 'METHOD' => 'Sabre\\VObject\\Property\\FlatText', - 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', - 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', + 'METHOD' => 'Sabre\\VObject\\Property\\FlatText', + 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', + 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', // Component properties - 'ATTACH' => 'Sabre\\VObject\\Property\\Uri', - 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', - 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', - 'COMMENT' => 'Sabre\\VObject\\Property\\FlatText', - 'DESCRIPTION' => 'Sabre\\VObject\\Property\\FlatText', - 'GEO' => 'Sabre\\VObject\\Property\\FloatValue', - 'LOCATION' => 'Sabre\\VObject\\Property\\FlatText', + 'ATTACH' => 'Sabre\\VObject\\Property\\Uri', + 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', + 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', + 'COMMENT' => 'Sabre\\VObject\\Property\\FlatText', + 'DESCRIPTION' => 'Sabre\\VObject\\Property\\FlatText', + 'GEO' => 'Sabre\\VObject\\Property\\FloatValue', + 'LOCATION' => 'Sabre\\VObject\\Property\\FlatText', 'PERCENT-COMPLETE' => 'Sabre\\VObject\\Property\\IntegerValue', - 'PRIORITY' => 'Sabre\\VObject\\Property\\IntegerValue', - 'RESOURCES' => 'Sabre\\VObject\\Property\\Text', - 'STATUS' => 'Sabre\\VObject\\Property\\FlatText', - 'SUMMARY' => 'Sabre\\VObject\\Property\\FlatText', + 'PRIORITY' => 'Sabre\\VObject\\Property\\IntegerValue', + 'RESOURCES' => 'Sabre\\VObject\\Property\\Text', + 'STATUS' => 'Sabre\\VObject\\Property\\FlatText', + 'SUMMARY' => 'Sabre\\VObject\\Property\\FlatText', // Date and Time Component Properties 'COMPLETED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTEND' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DUE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTSTART' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', - 'FREEBUSY' => 'Sabre\\VObject\\Property\\ICalendar\\Period', - 'TRANSP' => 'Sabre\\VObject\\Property\\FlatText', + 'DTEND' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'DUE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'DTSTART' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', + 'FREEBUSY' => 'Sabre\\VObject\\Property\\ICalendar\\Period', + 'TRANSP' => 'Sabre\\VObject\\Property\\FlatText', // Time Zone Component Properties - 'TZID' => 'Sabre\\VObject\\Property\\FlatText', - 'TZNAME' => 'Sabre\\VObject\\Property\\FlatText', + 'TZID' => 'Sabre\\VObject\\Property\\FlatText', + 'TZNAME' => 'Sabre\\VObject\\Property\\FlatText', 'TZOFFSETFROM' => 'Sabre\\VObject\\Property\\UtcOffset', - 'TZOFFSETTO' => 'Sabre\\VObject\\Property\\UtcOffset', - 'TZURL' => 'Sabre\\VObject\\Property\\Uri', + 'TZOFFSETTO' => 'Sabre\\VObject\\Property\\UtcOffset', + 'TZURL' => 'Sabre\\VObject\\Property\\Uri', // Relationship Component Properties - 'ATTENDEE' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', - 'CONTACT' => 'Sabre\\VObject\\Property\\FlatText', - 'ORGANIZER' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', + 'ATTENDEE' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', + 'CONTACT' => 'Sabre\\VObject\\Property\\FlatText', + 'ORGANIZER' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', 'RECURRENCE-ID' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RELATED-TO' => 'Sabre\\VObject\\Property\\FlatText', - 'URL' => 'Sabre\\VObject\\Property\\Uri', - 'UID' => 'Sabre\\VObject\\Property\\FlatText', + 'RELATED-TO' => 'Sabre\\VObject\\Property\\FlatText', + 'URL' => 'Sabre\\VObject\\Property\\Uri', + 'UID' => 'Sabre\\VObject\\Property\\FlatText', // Recurrence Component Properties 'EXDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', + 'RDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'RRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', 'EXRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', // Deprecated since rfc5545 // Alarm Component Properties - 'ACTION' => 'Sabre\\VObject\\Property\\FlatText', - 'REPEAT' => 'Sabre\\VObject\\Property\\IntegerValue', + 'ACTION' => 'Sabre\\VObject\\Property\\FlatText', + 'REPEAT' => 'Sabre\\VObject\\Property\\IntegerValue', 'TRIGGER' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', // Change Management Component Properties - 'CREATED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTSTAMP' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'CREATED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'DTSTAMP' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', 'LAST-MODIFIED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'SEQUENCE' => 'Sabre\\VObject\\Property\\IntegerValue', + 'SEQUENCE' => 'Sabre\\VObject\\Property\\IntegerValue', // Request Status 'REQUEST-STATUS' => 'Sabre\\VObject\\Property\\Text', // Additions from draft-daboo-valarm-extensions-04 - 'ALARM-AGENT' => 'Sabre\\VObject\\Property\\Text', - 'ACKNOWLEDGED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'PROXIMITY' => 'Sabre\\VObject\\Property\\Text', + 'ALARM-AGENT' => 'Sabre\\VObject\\Property\\Text', + 'ACKNOWLEDGED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', + 'PROXIMITY' => 'Sabre\\VObject\\Property\\Text', 'DEFAULT-ALARM' => 'Sabre\\VObject\\Property\\Boolean', // Additions from draft-daboo-calendar-availability-05 'BUSYTYPE' => 'Sabre\\VObject\\Property\\Text', - ]; /** @@ -158,10 +157,9 @@ class VCalendar extends VObject\Document { * * @return int */ - function getDocumentType() { - + public function getDocumentType() + { return self::ICALENDAR20; - } /** @@ -175,21 +173,20 @@ class VCalendar extends VObject\Document { * * @return VObject\Component[] */ - function getBaseComponents($componentName = null) { - - $isBaseComponent = function($component) { - + public function getBaseComponents($componentName = null) + { + $isBaseComponent = function ($component) { if (!$component instanceof VObject\Component) { return false; } - if ($component->name === 'VTIMEZONE') { + if ('VTIMEZONE' === $component->name) { return false; } if (isset($component->{'RECURRENCE-ID'})) { return false; } - return true; + return true; }; if ($componentName) { @@ -202,9 +199,7 @@ class VCalendar extends VObject\Document { $components = []; foreach ($this->children as $childGroup) { - foreach ($childGroup as $child) { - if (!$child instanceof Component) { // If one child is not a component, they all are so we skip // the entire group. @@ -213,12 +208,10 @@ class VCalendar extends VObject\Document { if ($isBaseComponent($child)) { $components[] = $child; } - } - } - return $components; + return $components; } /** @@ -231,21 +224,20 @@ class VCalendar extends VObject\Document { * * @return VObject\Component|null */ - function getBaseComponent($componentName = null) { - - $isBaseComponent = function($component) { - + public function getBaseComponent($componentName = null) + { + $isBaseComponent = function ($component) { if (!$component instanceof VObject\Component) { return false; } - if ($component->name === 'VTIMEZONE') { + if ('VTIMEZONE' === $component->name) { return false; } if (isset($component->{'RECURRENCE-ID'})) { return false; } - return true; + return true; }; if ($componentName) { @@ -254,6 +246,7 @@ class VCalendar extends VObject\Document { return $child; } } + return null; } @@ -264,10 +257,9 @@ class VCalendar extends VObject\Document { return $child; } } - } - return null; + return null; } /** @@ -277,7 +269,7 @@ class VCalendar extends VObject\Document { * If this calendar object, has events with recurrence rules, this method * can be used to expand the event into multiple sub-events. * - * Each event will be stripped from it's recurrence information, and only + * Each event will be stripped from its recurrence information, and only * the instances of the event in the specified timerange will be left * alone. * @@ -286,12 +278,13 @@ class VCalendar extends VObject\Document { * * @param DateTimeInterface $start * @param DateTimeInterface $end - * @param DateTimeZone $timeZone reference timezone for floating dates and - * times. + * @param DateTimeZone $timeZone reference timezone for floating dates and + * times + * * @return VCalendar */ - function expand(DateTimeInterface $start, DateTimeInterface $end, DateTimeZone $timeZone = null) { - + public function expand(DateTimeInterface $start, DateTimeInterface $end, DateTimeZone $timeZone = null) + { $newChildren = []; $recurringEvents = []; @@ -299,11 +292,9 @@ class VCalendar extends VObject\Document { $timeZone = new DateTimeZone('UTC'); } - $stripTimezones = function(Component $component) use ($timeZone, &$stripTimezones) { - + $stripTimezones = function (Component $component) use ($timeZone, &$stripTimezones) { foreach ($component->children() as $componentChild) { if ($componentChild instanceof Property\ICalendar\DateTime && $componentChild->hasTime()) { - $dt = $componentChild->getDateTimes($timeZone); // We only need to update the first timezone, because // setDateTimes will match all other timezones to the @@ -313,25 +304,22 @@ class VCalendar extends VObject\Document { } elseif ($componentChild instanceof Component) { $stripTimezones($componentChild); } - } - return $component; + return $component; }; foreach ($this->children() as $child) { - - if ($child instanceof Property && $child->name !== 'PRODID') { + if ($child instanceof Property && 'PRODID' !== $child->name) { // We explictly want to ignore PRODID, because we want to // overwrite it with our own. $newChildren[] = clone $child; - } elseif ($child instanceof Component && $child->name !== 'VTIMEZONE') { - + } elseif ($child instanceof Component && 'VTIMEZONE' !== $child->name) { // We're also stripping all VTIMEZONE objects because we're // converting everything to UTC. - if ($child->name === 'VEVENT' && (isset($child->{'RECURRENCE-ID'}) || isset($child->RRULE) || isset($child->RDATE))) { + if ('VEVENT' === $child->name && (isset($child->{'RECURRENCE-ID'}) || isset($child->RRULE) || isset($child->RDATE))) { // Handle these a bit later. - $uid = (string)$child->UID; + $uid = (string) $child->UID; if (!$uid) { throw new InvalidDataException('Every VEVENT object must have a UID property'); } @@ -340,19 +328,15 @@ class VCalendar extends VObject\Document { } else { $recurringEvents[$uid] = [clone $child]; } - } elseif ($child->name === 'VEVENT' && $child->isInTimeRange($start, $end)) { + } elseif ('VEVENT' === $child->name && $child->isInTimeRange($start, $end)) { $newChildren[] = $stripTimezones(clone $child); } - } - } foreach ($recurringEvents as $events) { - try { $it = new EventIterator($events, $timeZone); - } catch (NoInstancesException $e) { // This event is recurring, but it doesn't have a single // instance. We are skipping this event from the output @@ -362,20 +346,14 @@ class VCalendar extends VObject\Document { $it->fastForward($start); while ($it->valid() && $it->getDTStart() < $end) { - if ($it->getDTEnd() > $start) { - $newChildren[] = $stripTimezones($it->getEventObject()); - } $it->next(); - } - } return new self($newChildren); - } /** @@ -383,14 +361,13 @@ class VCalendar extends VObject\Document { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return [ - 'VERSION' => '2.0', - 'PRODID' => '-//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN', + 'VERSION' => '2.0', + 'PRODID' => '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN', 'CALSCALE' => 'GREGORIAN', ]; - } /** @@ -408,16 +385,15 @@ class VCalendar extends VObject\Document { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'PRODID' => 1, + 'PRODID' => 1, 'VERSION' => 1, 'CALSCALE' => '?', - 'METHOD' => '?', + 'METHOD' => '?', ]; - } /** @@ -444,19 +420,18 @@ class VCalendar extends VObject\Document { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $warnings = parent::validate($options); if ($ver = $this->VERSION) { - if ((string)$ver !== '2.0') { + if ('2.0' !== (string) $ver) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'Only iCalendar version 2.0 as defined in rfc5545 is supported.', - 'node' => $this, + 'node' => $this, ]; } - } $uidList = []; @@ -465,77 +440,75 @@ class VCalendar extends VObject\Document { foreach ($this->children() as $child) { if ($child instanceof Component) { - $componentsFound++; + ++$componentsFound; if (!in_array($child->name, ['VEVENT', 'VTODO', 'VJOURNAL'])) { continue; } $componentTypes[] = $child->name; - $uid = (string)$child->UID; + $uid = (string) $child->UID; $isMaster = isset($child->{'RECURRENCE-ID'}) ? 0 : 1; if (isset($uidList[$uid])) { - $uidList[$uid]['count']++; + ++$uidList[$uid]['count']; if ($isMaster && $uidList[$uid]['hasMaster']) { $warnings[] = [ - 'level' => 3, - 'message' => 'More than one master object was found for the object with UID ' . $uid, - 'node' => $this, + 'level' => 3, + 'message' => 'More than one master object was found for the object with UID '.$uid, + 'node' => $this, ]; } $uidList[$uid]['hasMaster'] += $isMaster; } else { $uidList[$uid] = [ - 'count' => 1, + 'count' => 1, 'hasMaster' => $isMaster, ]; } - } } - if ($componentsFound === 0) { + if (0 === $componentsFound) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'An iCalendar object must have at least 1 component.', - 'node' => $this, + 'node' => $this, ]; } if ($options & self::PROFILE_CALDAV) { if (count($uidList) > 1) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'A calendar object on a CalDAV server may only have components with the same UID.', - 'node' => $this, + 'node' => $this, ]; } - if (count($componentTypes) === 0) { + if (0 === count($componentTypes)) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'A calendar object on a CalDAV server must have at least 1 component (VTODO, VEVENT, VJOURNAL).', - 'node' => $this, + 'node' => $this, ]; } if (count(array_unique($componentTypes)) > 1) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'A calendar object on a CalDAV server may only have 1 type of component (VEVENT, VTODO or VJOURNAL).', - 'node' => $this, + 'node' => $this, ]; } if (isset($this->METHOD)) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'A calendar object on a CalDAV server MUST NOT have a METHOD property.', - 'node' => $this, + 'node' => $this, ]; } } return $warnings; - } /** @@ -543,19 +516,15 @@ class VCalendar extends VObject\Document { * * @return array */ - function getByUID($uid) { - - return array_filter($this->getComponents(), function($item) use ($uid) { - + public function getByUID($uid) + { + return array_filter($this->getComponents(), function ($item) use ($uid) { if (!$itemUid = $item->select('UID')) { return false; } $itemUid = current($itemUid)->getValue(); - return $uid === $itemUid; + return $uid === $itemUid; }); - } - - } diff --git a/vendor/sabre/vobject/lib/Component/VCard.php b/vendor/sabre/vobject/lib/Component/VCard.php index bca623d5e..860e45ffa 100644 --- a/vendor/sabre/vobject/lib/Component/VCard.php +++ b/vendor/sabre/vobject/lib/Component/VCard.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VCard extends VObject\Document { - +class VCard extends VObject\Document +{ /** * The default name for this component. * @@ -24,7 +24,7 @@ class VCard extends VObject\Document { * * @var string */ - static $defaultName = 'VCARD'; + public static $defaultName = 'VCARD'; /** * Caching the version number. @@ -38,7 +38,7 @@ class VCard extends VObject\Document { * * @var array */ - static $componentMap = [ + public static $componentMap = [ 'VCARD' => 'Sabre\\VObject\\Component\\VCard', ]; @@ -47,23 +47,23 @@ class VCard extends VObject\Document { * * @var array */ - static $valueMap = [ - 'BINARY' => 'Sabre\\VObject\\Property\\Binary', - 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', - 'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only - 'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date', - 'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime', + public static $valueMap = [ + 'BINARY' => 'Sabre\\VObject\\Property\\Binary', + 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', + 'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only + 'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date', + 'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime', 'DATE-AND-OR-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only - 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', - 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', - 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'TEXT' => 'Sabre\\VObject\\Property\\Text', - 'TIME' => 'Sabre\\VObject\\Property\\Time', - 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. - 'URI' => 'Sabre\\VObject\\Property\\Uri', - 'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only - 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', + 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', + 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', + 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', + 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', + 'TEXT' => 'Sabre\\VObject\\Property\\Text', + 'TIME' => 'Sabre\\VObject\\Property\\Time', + 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. + 'URI' => 'Sabre\\VObject\\Property\\Uri', + 'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only + 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', ]; /** @@ -71,72 +71,70 @@ class VCard extends VObject\Document { * * @var array */ - static $propertyMap = [ - + public static $propertyMap = [ // vCard 2.1 properties and up - 'N' => 'Sabre\\VObject\\Property\\Text', - 'FN' => 'Sabre\\VObject\\Property\\FlatText', - 'PHOTO' => 'Sabre\\VObject\\Property\\Binary', - 'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', - 'ADR' => 'Sabre\\VObject\\Property\\Text', - 'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'TEL' => 'Sabre\\VObject\\Property\\FlatText', - 'EMAIL' => 'Sabre\\VObject\\Property\\FlatText', + 'N' => 'Sabre\\VObject\\Property\\Text', + 'FN' => 'Sabre\\VObject\\Property\\FlatText', + 'PHOTO' => 'Sabre\\VObject\\Property\\Binary', + 'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'ADR' => 'Sabre\\VObject\\Property\\Text', + 'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 + 'TEL' => 'Sabre\\VObject\\Property\\FlatText', + 'EMAIL' => 'Sabre\\VObject\\Property\\FlatText', 'MAILER' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'GEO' => 'Sabre\\VObject\\Property\\FlatText', - 'TITLE' => 'Sabre\\VObject\\Property\\FlatText', - 'ROLE' => 'Sabre\\VObject\\Property\\FlatText', - 'LOGO' => 'Sabre\\VObject\\Property\\Binary', + 'GEO' => 'Sabre\\VObject\\Property\\FlatText', + 'TITLE' => 'Sabre\\VObject\\Property\\FlatText', + 'ROLE' => 'Sabre\\VObject\\Property\\FlatText', + 'LOGO' => 'Sabre\\VObject\\Property\\Binary', // 'AGENT' => 'Sabre\\VObject\\Property\\', // Todo: is an embedded vCard. Probably rare, so // not supported at the moment - 'ORG' => 'Sabre\\VObject\\Property\\Text', - 'NOTE' => 'Sabre\\VObject\\Property\\FlatText', - 'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'SOUND' => 'Sabre\\VObject\\Property\\FlatText', - 'URL' => 'Sabre\\VObject\\Property\\Uri', - 'UID' => 'Sabre\\VObject\\Property\\FlatText', + 'ORG' => 'Sabre\\VObject\\Property\\Text', + 'NOTE' => 'Sabre\\VObject\\Property\\FlatText', + 'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', + 'SOUND' => 'Sabre\\VObject\\Property\\FlatText', + 'URL' => 'Sabre\\VObject\\Property\\Uri', + 'UID' => 'Sabre\\VObject\\Property\\FlatText', 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', - 'KEY' => 'Sabre\\VObject\\Property\\FlatText', - 'TZ' => 'Sabre\\VObject\\Property\\Text', + 'KEY' => 'Sabre\\VObject\\Property\\FlatText', + 'TZ' => 'Sabre\\VObject\\Property\\Text', // vCard 3.0 properties - 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', + 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', 'SORT-STRING' => 'Sabre\\VObject\\Property\\FlatText', - 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', - 'NICKNAME' => 'Sabre\\VObject\\Property\\Text', - 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 + 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', + 'NICKNAME' => 'Sabre\\VObject\\Property\\Text', + 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 // rfc2739 properties - 'FBURL' => 'Sabre\\VObject\\Property\\Uri', - 'CAPURI' => 'Sabre\\VObject\\Property\\Uri', - 'CALURI' => 'Sabre\\VObject\\Property\\Uri', + 'FBURL' => 'Sabre\\VObject\\Property\\Uri', + 'CAPURI' => 'Sabre\\VObject\\Property\\Uri', + 'CALURI' => 'Sabre\\VObject\\Property\\Uri', 'CALADRURI' => 'Sabre\\VObject\\Property\\Uri', // rfc4770 properties 'IMPP' => 'Sabre\\VObject\\Property\\Uri', // vCard 4.0 properties - 'SOURCE' => 'Sabre\\VObject\\Property\\Uri', - 'XML' => 'Sabre\\VObject\\Property\\FlatText', - 'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'SOURCE' => 'Sabre\\VObject\\Property\\Uri', + 'XML' => 'Sabre\\VObject\\Property\\FlatText', + 'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', 'CLIENTPIDMAP' => 'Sabre\\VObject\\Property\\Text', - 'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'GENDER' => 'Sabre\\VObject\\Property\\Text', - 'KIND' => 'Sabre\\VObject\\Property\\FlatText', - 'MEMBER' => 'Sabre\\VObject\\Property\\Uri', - 'RELATED' => 'Sabre\\VObject\\Property\\Uri', + 'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', + 'GENDER' => 'Sabre\\VObject\\Property\\Text', + 'KIND' => 'Sabre\\VObject\\Property\\FlatText', + 'MEMBER' => 'Sabre\\VObject\\Property\\Uri', + 'RELATED' => 'Sabre\\VObject\\Property\\Uri', // rfc6474 properties 'BIRTHPLACE' => 'Sabre\\VObject\\Property\\FlatText', 'DEATHPLACE' => 'Sabre\\VObject\\Property\\FlatText', - 'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // rfc6715 properties - 'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText', - 'HOBBY' => 'Sabre\\VObject\\Property\\FlatText', - 'INTEREST' => 'Sabre\\VObject\\Property\\FlatText', + 'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText', + 'HOBBY' => 'Sabre\\VObject\\Property\\FlatText', + 'INTEREST' => 'Sabre\\VObject\\Property\\FlatText', 'ORG-DIRECTORY' => 'Sabre\\VObject\\Property\\FlatText', - ]; /** @@ -144,23 +142,22 @@ class VCard extends VObject\Document { * * @return int */ - function getDocumentType() { - + public function getDocumentType() + { if (!$this->version) { - - $version = (string)$this->VERSION; + $version = (string) $this->VERSION; switch ($version) { - case '2.1' : + case '2.1': $this->version = self::VCARD21; break; - case '3.0' : + case '3.0': $this->version = self::VCARD30; break; - case '4.0' : + case '4.0': $this->version = self::VCARD40; break; - default : + default: // We don't want to cache the version if it's unknown, // because we might get a version property in a bit. return self::UNKNOWN; @@ -168,7 +165,6 @@ class VCard extends VObject\Document { } return $this->version; - } /** @@ -185,11 +181,11 @@ class VCard extends VObject\Document { * * @return VCard */ - function convert($target) { - + public function convert($target) + { $converter = new VObject\VCardConverter(); - return $converter->convert($this, $target); + return $converter->convert($this, $target); } /** @@ -221,8 +217,8 @@ class VCard extends VObject\Document { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $warnings = []; $versionMap = [ @@ -232,29 +228,28 @@ class VCard extends VObject\Document { ]; $version = $this->select('VERSION'); - if (count($version) === 1) { - $version = (string)$this->VERSION; - if ($version !== '2.1' && $version !== '3.0' && $version !== '4.0') { + if (1 === count($version)) { + $version = (string) $this->VERSION; + if ('2.1' !== $version && '3.0' !== $version && '4.0' !== $version) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', - 'node' => $this, + 'node' => $this, ]; if ($options & self::REPAIR) { $this->VERSION = $versionMap[self::DEFAULT_VERSION]; } } - if ($version === '2.1' && ($options & self::PROFILE_CARDDAV)) { + if ('2.1' === $version && ($options & self::PROFILE_CARDDAV)) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'CardDAV servers are not allowed to accept vCard 2.1.', - 'node' => $this, + 'node' => $this, ]; } - } $uid = $this->select('UID'); - if (count($uid) === 0) { + if (0 === count($uid)) { if ($options & self::PROFILE_CARDDAV) { // Required for CardDAV $warningLevel = 3; @@ -269,23 +264,22 @@ class VCard extends VObject\Document { $warningLevel = 1; } $warnings[] = [ - 'level' => $warningLevel, + 'level' => $warningLevel, 'message' => $message, - 'node' => $this, + 'node' => $this, ]; } $fn = $this->select('FN'); - if (count($fn) !== 1) { - + if (1 !== count($fn)) { $repaired = false; - if (($options & self::REPAIR) && count($fn) === 0) { + if (($options & self::REPAIR) && 0 === count($fn)) { // We're going to try to see if we can use the contents of the // N property. if (isset($this->N)) { - $value = explode(';', (string)$this->N); + $value = explode(';', (string) $this->N); if (isset($value[1]) && $value[1]) { - $this->FN = $value[1] . ' ' . $value[0]; + $this->FN = $value[1].' '.$value[0]; } else { $this->FN = $value[0]; } @@ -293,20 +287,19 @@ class VCard extends VObject\Document { // Otherwise, the ORG property may work } elseif (isset($this->ORG)) { - $this->FN = (string)$this->ORG; + $this->FN = (string) $this->ORG; $repaired = true; // Otherwise, the EMAIL property may work } elseif (isset($this->EMAIL)) { - $this->FN = (string)$this->EMAIL; + $this->FN = (string) $this->EMAIL; $repaired = true; } - } $warnings[] = [ - 'level' => $repaired ? 1 : 3, + 'level' => $repaired ? 1 : 3, 'message' => 'The FN property must appear in the VCARD component exactly 1 time', - 'node' => $this, + 'node' => $this, ]; } @@ -314,7 +307,6 @@ class VCard extends VObject\Document { parent::validate($options), $warnings ); - } /** @@ -332,50 +324,49 @@ class VCard extends VObject\Document { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'ADR' => '*', - 'ANNIVERSARY' => '?', - 'BDAY' => '?', - 'CALADRURI' => '*', - 'CALURI' => '*', - 'CATEGORIES' => '*', + 'ADR' => '*', + 'ANNIVERSARY' => '?', + 'BDAY' => '?', + 'CALADRURI' => '*', + 'CALURI' => '*', + 'CATEGORIES' => '*', 'CLIENTPIDMAP' => '*', - 'EMAIL' => '*', - 'FBURL' => '*', - 'IMPP' => '*', - 'GENDER' => '?', - 'GEO' => '*', - 'KEY' => '*', - 'KIND' => '?', - 'LANG' => '*', - 'LOGO' => '*', - 'MEMBER' => '*', - 'N' => '?', - 'NICKNAME' => '*', - 'NOTE' => '*', - 'ORG' => '*', - 'PHOTO' => '*', - 'PRODID' => '?', - 'RELATED' => '*', - 'REV' => '?', - 'ROLE' => '*', - 'SOUND' => '*', - 'SOURCE' => '*', - 'TEL' => '*', - 'TITLE' => '*', - 'TZ' => '*', - 'URL' => '*', - 'VERSION' => '1', - 'XML' => '*', + 'EMAIL' => '*', + 'FBURL' => '*', + 'IMPP' => '*', + 'GENDER' => '?', + 'GEO' => '*', + 'KEY' => '*', + 'KIND' => '?', + 'LANG' => '*', + 'LOGO' => '*', + 'MEMBER' => '*', + 'N' => '?', + 'NICKNAME' => '*', + 'NOTE' => '*', + 'ORG' => '*', + 'PHOTO' => '*', + 'PRODID' => '?', + 'RELATED' => '*', + 'REV' => '?', + 'ROLE' => '*', + 'SOUND' => '*', + 'SOURCE' => '*', + 'TEL' => '*', + 'TITLE' => '*', + 'TZ' => '*', + 'URL' => '*', + 'VERSION' => '1', + 'XML' => '*', // FN is commented out, because it's already handled by the // validate function, which may also try to repair it. // 'FN' => '+', 'UID' => '?', ]; - } /** @@ -392,12 +383,11 @@ class VCard extends VObject\Document { * * @return VObject\Property|null */ - function preferred($propertyName) { - + public function preferred($propertyName) + { $preferred = null; $lastPref = 101; foreach ($this->select($propertyName) as $field) { - $pref = 101; if (isset($field['TYPE']) && $field['TYPE']->has('PREF')) { $pref = 1; @@ -409,10 +399,9 @@ class VCard extends VObject\Document { $preferred = $field; $lastPref = $pref; } - } - return $preferred; + return $preferred; } /** @@ -426,7 +415,8 @@ class VCard extends VObject\Document { * * @return VObject\Property|null */ - function getByType($propertyName, $type) { + public function getByType($propertyName, $type) + { foreach ($this->select($propertyName) as $field) { if (isset($field['TYPE']) && $field['TYPE']->has($type)) { return $field; @@ -439,14 +429,13 @@ class VCard extends VObject\Document { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return [ 'VERSION' => '4.0', - 'PRODID' => '-//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN', - 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(), + 'PRODID' => '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN', + 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), ]; - } /** @@ -455,8 +444,8 @@ class VCard extends VObject\Document { * * @return array */ - function jsonSerialize() { - + public function jsonSerialize() + { // A vcard does not have sub-components, so we're overriding this // method to remove that array element. $properties = []; @@ -469,23 +458,19 @@ class VCard extends VObject\Document { strtolower($this->name), $properties, ]; - } /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - function xmlSerialize(Xml\Writer $writer) { - + public function xmlSerialize(Xml\Writer $writer) + { $propertiesByGroup = []; foreach ($this->children() as $property) { - $group = $property->group; if (!isset($propertiesByGroup[$group])) { @@ -493,25 +478,20 @@ class VCard extends VObject\Document { } $propertiesByGroup[$group][] = $property; - } $writer->startElement(strtolower($this->name)); foreach ($propertiesByGroup as $group => $properties) { - if (!empty($group)) { - $writer->startElement('group'); $writer->writeAttribute('name', strtolower($group)); - } foreach ($properties as $property) { switch ($property->name) { - case 'VERSION': - continue; + break; case 'XML': $value = $property->getParts(); @@ -522,18 +502,15 @@ class VCard extends VObject\Document { default: $property->xmlSerialize($writer); break; - } } if (!empty($group)) { $writer->endElement(); } - } $writer->endElement(); - } /** @@ -543,16 +520,15 @@ class VCard extends VObject\Document { * * @return string */ - function getClassNameForPropertyName($propertyName) { - + public function getClassNameForPropertyName($propertyName) + { $className = parent::getClassNameForPropertyName($propertyName); // In vCard 4, BINARY no longer exists, and we need URI instead. - if ($className == 'Sabre\\VObject\\Property\\Binary' && $this->getDocumentType() === self::VCARD40) { + if ('Sabre\\VObject\\Property\\Binary' == $className && self::VCARD40 === $this->getDocumentType()) { return 'Sabre\\VObject\\Property\\Uri'; } - return $className; + return $className; } - } diff --git a/vendor/sabre/vobject/lib/Component/VEvent.php b/vendor/sabre/vobject/lib/Component/VEvent.php index 7f6861190..09f37033c 100644 --- a/vendor/sabre/vobject/lib/Component/VEvent.php +++ b/vendor/sabre/vobject/lib/Component/VEvent.php @@ -16,8 +16,8 @@ use Sabre\VObject\Recur\NoInstancesException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VEvent extends VObject\Component { - +class VEvent extends VObject\Component +{ /** * Returns true or false depending on if the event falls in the specified * time-range. This is used for filtering purposes. @@ -30,20 +30,15 @@ class VEvent extends VObject\Component { * * @return bool */ - function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) { - + public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) + { if ($this->RRULE) { - try { - $it = new EventIterator($this, null, $start->getTimezone()); - } catch (NoInstancesException $e) { - // If we've catched this exception, there are no instances // for the event that fall into the specified time-range. return false; - } $it->fastForward($start); @@ -54,13 +49,11 @@ class VEvent extends VObject\Component { // // If the starttime of the recurrence did not exceed the // end of the time range as well, we have a match. - return ($it->getDTStart() < $end && $it->getDTEnd() > $start); - + return $it->getDTStart() < $end && $it->getDTEnd() > $start; } $effectiveStart = $this->DTSTART->getDateTime($start->getTimezone()); if (isset($this->DTEND)) { - // The DTEND property is considered non inclusive. So for a 3 day // event in july, dtstart and dtend would have to be July 1st and // July 4th respectively. @@ -68,7 +61,6 @@ class VEvent extends VObject\Component { // See: // http://tools.ietf.org/html/rfc5545#page-54 $effectiveEnd = $this->DTEND->getDateTime($end->getTimezone()); - } elseif (isset($this->DURATION)) { $effectiveEnd = $effectiveStart->add(VObject\DateTimeParser::parseDuration($this->DURATION)); } elseif (!$this->DTSTART->hasTime()) { @@ -76,10 +68,10 @@ class VEvent extends VObject\Component { } else { $effectiveEnd = $effectiveStart; } - return ( - ($start < $effectiveEnd) && ($end > $effectiveStart) - ); + return + ($start < $effectiveEnd) && ($end > $effectiveStart) + ; } /** @@ -87,13 +79,12 @@ class VEvent extends VObject\Component { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return [ - 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(), - 'DTSTAMP' => date('Ymd\\THis\\Z'), + 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), + 'DTSTAMP' => gmdate('Ymd\\THis\\Z'), ]; - } /** @@ -111,43 +102,42 @@ class VEvent extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { $hasMethod = isset($this->parent->METHOD); + return [ - 'UID' => 1, - 'DTSTAMP' => 1, - 'DTSTART' => $hasMethod ? '?' : '1', - 'CLASS' => '?', - 'CREATED' => '?', - 'DESCRIPTION' => '?', - 'GEO' => '?', + 'UID' => 1, + 'DTSTAMP' => 1, + 'DTSTART' => $hasMethod ? '?' : '1', + 'CLASS' => '?', + 'CREATED' => '?', + 'DESCRIPTION' => '?', + 'GEO' => '?', 'LAST-MODIFIED' => '?', - 'LOCATION' => '?', - 'ORGANIZER' => '?', - 'PRIORITY' => '?', - 'SEQUENCE' => '?', - 'STATUS' => '?', - 'SUMMARY' => '?', - 'TRANSP' => '?', - 'URL' => '?', + 'LOCATION' => '?', + 'ORGANIZER' => '?', + 'PRIORITY' => '?', + 'SEQUENCE' => '?', + 'STATUS' => '?', + 'SUMMARY' => '?', + 'TRANSP' => '?', + 'URL' => '?', 'RECURRENCE-ID' => '?', - 'RRULE' => '?', - 'DTEND' => '?', - 'DURATION' => '?', - - 'ATTACH' => '*', - 'ATTENDEE' => '*', - 'CATEGORIES' => '*', - 'COMMENT' => '*', - 'CONTACT' => '*', - 'EXDATE' => '*', + 'RRULE' => '?', + 'DTEND' => '?', + 'DURATION' => '?', + + 'ATTACH' => '*', + 'ATTENDEE' => '*', + 'CATEGORIES' => '*', + 'COMMENT' => '*', + 'CONTACT' => '*', + 'EXDATE' => '*', 'REQUEST-STATUS' => '*', - 'RELATED-TO' => '*', - 'RESOURCES' => '*', - 'RDATE' => '*', + 'RELATED-TO' => '*', + 'RESOURCES' => '*', + 'RDATE' => '*', ]; - } - } diff --git a/vendor/sabre/vobject/lib/Component/VFreeBusy.php b/vendor/sabre/vobject/lib/Component/VFreeBusy.php index 72294cc9f..558a85233 100644 --- a/vendor/sabre/vobject/lib/Component/VFreeBusy.php +++ b/vendor/sabre/vobject/lib/Component/VFreeBusy.php @@ -15,8 +15,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VFreeBusy extends VObject\Component { - +class VFreeBusy extends VObject\Component +{ /** * Checks based on the contained FREEBUSY information, if a timeslot is * available. @@ -26,19 +26,18 @@ class VFreeBusy extends VObject\Component { * * @return bool */ - function isFree(DateTimeInterface $start, DatetimeInterface $end) { - + public function isFree(DateTimeInterface $start, DatetimeInterface $end) + { foreach ($this->select('FREEBUSY') as $freebusy) { - // We are only interested in FBTYPE=BUSY (the default), // FBTYPE=BUSY-TENTATIVE or FBTYPE=BUSY-UNAVAILABLE. - if (isset($freebusy['FBTYPE']) && strtoupper(substr((string)$freebusy['FBTYPE'], 0, 4)) !== 'BUSY') { + if (isset($freebusy['FBTYPE']) && 'BUSY' !== strtoupper(substr((string) $freebusy['FBTYPE'], 0, 4))) { continue; } // The freebusy component can hold more than 1 value, separated by // commas. - $periods = explode(',', (string)$freebusy); + $periods = explode(',', (string) $freebusy); foreach ($periods as $period) { // Every period is formatted as [start]/[end]. The start is an @@ -55,13 +54,10 @@ class VFreeBusy extends VObject\Component { if ($start < $busyEnd && $end > $busyStart) { return false; } - } - } return true; - } /** @@ -79,24 +75,22 @@ class VFreeBusy extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'UID' => 1, + 'UID' => 1, 'DTSTAMP' => 1, - 'CONTACT' => '?', - 'DTSTART' => '?', - 'DTEND' => '?', + 'CONTACT' => '?', + 'DTSTART' => '?', + 'DTEND' => '?', 'ORGANIZER' => '?', - 'URL' => '?', + 'URL' => '?', - 'ATTENDEE' => '*', - 'COMMENT' => '*', - 'FREEBUSY' => '*', + 'ATTENDEE' => '*', + 'COMMENT' => '*', + 'FREEBUSY' => '*', 'REQUEST-STATUS' => '*', ]; - } - } diff --git a/vendor/sabre/vobject/lib/Component/VJournal.php b/vendor/sabre/vobject/lib/Component/VJournal.php index a1b1a863d..9bd336776 100644 --- a/vendor/sabre/vobject/lib/Component/VJournal.php +++ b/vendor/sabre/vobject/lib/Component/VJournal.php @@ -14,8 +14,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VJournal extends VObject\Component { - +class VJournal extends VObject\Component +{ /** * Returns true or false depending on if the event falls in the specified * time-range. This is used for filtering purposes. @@ -28,8 +28,8 @@ class VJournal extends VObject\Component { * * @return bool */ - function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) { - + public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) + { $dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null; if ($dtstart) { $effectiveEnd = $dtstart; @@ -37,11 +37,10 @@ class VJournal extends VObject\Component { $effectiveEnd = $effectiveEnd->modify('+1 day'); } - return ($start <= $effectiveEnd && $end > $dtstart); - + return $start <= $effectiveEnd && $end > $dtstart; } - return false; + return false; } /** @@ -59,36 +58,35 @@ class VJournal extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'UID' => 1, + 'UID' => 1, 'DTSTAMP' => 1, - 'CLASS' => '?', - 'CREATED' => '?', - 'DTSTART' => '?', + 'CLASS' => '?', + 'CREATED' => '?', + 'DTSTART' => '?', 'LAST-MODIFIED' => '?', - 'ORGANIZER' => '?', + 'ORGANIZER' => '?', 'RECURRENCE-ID' => '?', - 'SEQUENCE' => '?', - 'STATUS' => '?', - 'SUMMARY' => '?', - 'URL' => '?', + 'SEQUENCE' => '?', + 'STATUS' => '?', + 'SUMMARY' => '?', + 'URL' => '?', 'RRULE' => '?', - 'ATTACH' => '*', - 'ATTENDEE' => '*', - 'CATEGORIES' => '*', - 'COMMENT' => '*', - 'CONTACT' => '*', + 'ATTACH' => '*', + 'ATTENDEE' => '*', + 'CATEGORIES' => '*', + 'COMMENT' => '*', + 'CONTACT' => '*', 'DESCRIPTION' => '*', - 'EXDATE' => '*', - 'RELATED-TO' => '*', - 'RDATE' => '*', + 'EXDATE' => '*', + 'RELATED-TO' => '*', + 'RDATE' => '*', ]; - } /** @@ -96,12 +94,11 @@ class VJournal extends VObject\Component { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return [ - 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(), - 'DTSTAMP' => date('Ymd\\THis\\Z'), + 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), + 'DTSTAMP' => gmdate('Ymd\\THis\\Z'), ]; - } } diff --git a/vendor/sabre/vobject/lib/Component/VTimeZone.php b/vendor/sabre/vobject/lib/Component/VTimeZone.php index f6eb6cba1..21c062377 100644 --- a/vendor/sabre/vobject/lib/Component/VTimeZone.php +++ b/vendor/sabre/vobject/lib/Component/VTimeZone.php @@ -14,8 +14,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VTimeZone extends VObject\Component { - +class VTimeZone extends VObject\Component +{ /** * Returns the PHP DateTimeZone for this VTIMEZONE component. * @@ -24,10 +24,9 @@ class VTimeZone extends VObject\Component { * * @return \DateTimeZone */ - function getTimeZone() { - - return VObject\TimeZoneUtil::getTimeZone((string)$this->TZID, $this->root); - + public function getTimeZone() + { + return VObject\TimeZoneUtil::getTimeZone((string) $this->TZID, $this->root); } /** @@ -45,13 +44,13 @@ class VTimeZone extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ 'TZID' => 1, 'LAST-MODIFIED' => '?', - 'TZURL' => '?', + 'TZURL' => '?', // At least 1 STANDARD or DAYLIGHT must appear. // @@ -60,7 +59,5 @@ class VTimeZone extends VObject\Component { 'STANDARD' => '*', 'DAYLIGHT' => '*', ]; - } - } diff --git a/vendor/sabre/vobject/lib/Component/VTodo.php b/vendor/sabre/vobject/lib/Component/VTodo.php index 144ced694..9de77e841 100644 --- a/vendor/sabre/vobject/lib/Component/VTodo.php +++ b/vendor/sabre/vobject/lib/Component/VTodo.php @@ -14,8 +14,8 @@ use Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VTodo extends VObject\Component { - +class VTodo extends VObject\Component +{ /** * Returns true or false depending on if the event falls in the specified * time-range. This is used for filtering purposes. @@ -28,8 +28,8 @@ class VTodo extends VObject\Component { * * @return bool */ - function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) { - + public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) + { $dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null; $duration = isset($this->DURATION) ? VObject\DateTimeParser::parseDuration($this->DURATION) : null; $due = isset($this->DUE) ? $this->DUE->getDateTime() : null; @@ -39,6 +39,7 @@ class VTodo extends VObject\Component { if ($dtstart) { if ($duration) { $effectiveEnd = $dtstart->add($duration); + return $start <= $effectiveEnd && $end > $dtstart; } elseif ($due) { return @@ -49,7 +50,7 @@ class VTodo extends VObject\Component { } } if ($due) { - return ($start < $due && $end >= $due); + return $start < $due && $end >= $due; } if ($completed && $created) { return @@ -57,13 +58,13 @@ class VTodo extends VObject\Component { ($end >= $created || $end >= $completed); } if ($completed) { - return ($start <= $completed && $end >= $completed); + return $start <= $completed && $end >= $completed; } if ($created) { - return ($end > $created); + return $end > $created; } - return true; + return true; } /** @@ -81,45 +82,44 @@ class VTodo extends VObject\Component { * * @var array */ - function getValidationRules() { - + public function getValidationRules() + { return [ - 'UID' => 1, + 'UID' => 1, 'DTSTAMP' => 1, - 'CLASS' => '?', - 'COMPLETED' => '?', - 'CREATED' => '?', - 'DESCRIPTION' => '?', - 'DTSTART' => '?', - 'GEO' => '?', + 'CLASS' => '?', + 'COMPLETED' => '?', + 'CREATED' => '?', + 'DESCRIPTION' => '?', + 'DTSTART' => '?', + 'GEO' => '?', 'LAST-MODIFIED' => '?', - 'LOCATION' => '?', - 'ORGANIZER' => '?', - 'PERCENT' => '?', - 'PRIORITY' => '?', + 'LOCATION' => '?', + 'ORGANIZER' => '?', + 'PERCENT' => '?', + 'PRIORITY' => '?', 'RECURRENCE-ID' => '?', - 'SEQUENCE' => '?', - 'STATUS' => '?', - 'SUMMARY' => '?', - 'URL' => '?', + 'SEQUENCE' => '?', + 'STATUS' => '?', + 'SUMMARY' => '?', + 'URL' => '?', - 'RRULE' => '?', - 'DUE' => '?', + 'RRULE' => '?', + 'DUE' => '?', 'DURATION' => '?', - 'ATTACH' => '*', - 'ATTENDEE' => '*', - 'CATEGORIES' => '*', - 'COMMENT' => '*', - 'CONTACT' => '*', - 'EXDATE' => '*', + 'ATTACH' => '*', + 'ATTENDEE' => '*', + 'CATEGORIES' => '*', + 'COMMENT' => '*', + 'CONTACT' => '*', + 'EXDATE' => '*', 'REQUEST-STATUS' => '*', - 'RELATED-TO' => '*', - 'RESOURCES' => '*', - 'RDATE' => '*', + 'RELATED-TO' => '*', + 'RESOURCES' => '*', + 'RDATE' => '*', ]; - } /** @@ -144,36 +144,29 @@ class VTodo extends VObject\Component { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $result = parent::validate($options); if (isset($this->DUE) && isset($this->DTSTART)) { - $due = $this->DUE; $dtStart = $this->DTSTART; if ($due->getValueType() !== $dtStart->getValueType()) { - $result[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'The value type (DATE or DATE-TIME) must be identical for DUE and DTSTART', - 'node' => $due, + 'node' => $due, ]; - } elseif ($due->getDateTime() < $dtStart->getDateTime()) { - $result[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'DUE must occur after DTSTART', - 'node' => $due, + 'node' => $due, ]; - } - } return $result; - } /** @@ -181,13 +174,11 @@ class VTodo extends VObject\Component { * * @return array */ - protected function getDefaults() { - + protected function getDefaults() + { return [ - 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(), + 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), 'DTSTAMP' => date('Ymd\\THis\\Z'), ]; - } - } diff --git a/vendor/sabre/vobject/lib/DateTimeParser.php b/vendor/sabre/vobject/lib/DateTimeParser.php index f9a802d25..1c253437a 100644 --- a/vendor/sabre/vobject/lib/DateTimeParser.php +++ b/vendor/sabre/vobject/lib/DateTimeParser.php @@ -16,8 +16,8 @@ use DateTimeZone; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateTimeParser { - +class DateTimeParser +{ /** * Parses an iCalendar (rfc5545) formatted datetime and returns a * DateTimeImmutable object. @@ -26,49 +26,48 @@ class DateTimeParser { * if the non-UTC format is used. The argument is used as a reference, the * returned DateTimeImmutable object will still be in the UTC timezone. * - * @param string $dt + * @param string $dt * @param DateTimeZone $tz * * @return DateTimeImmutable */ - static function parseDateTime($dt, DateTimeZone $tz = null) { - + public static function parseDateTime($dt, DateTimeZone $tz = null) + { // Format is YYYYMMDD + "T" + hhmmss $result = preg_match('/^([0-9]{4})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/', $dt, $matches); if (!$result) { - throw new InvalidDataException('The supplied iCalendar datetime value is incorrect: ' . $dt); + throw new InvalidDataException('The supplied iCalendar datetime value is incorrect: '.$dt); } - if ($matches[7] === 'Z' || is_null($tz)) { + if ('Z' === $matches[7] || is_null($tz)) { $tz = new DateTimeZone('UTC'); } try { - $date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] . ':' . $matches[6], $tz); + $date = new DateTimeImmutable($matches[1].'-'.$matches[2].'-'.$matches[3].' '.$matches[4].':'.$matches[5].':'.$matches[6], $tz); } catch (\Exception $e) { - throw new InvalidDataException('The supplied iCalendar datetime value is incorrect: ' . $dt); + throw new InvalidDataException('The supplied iCalendar datetime value is incorrect: '.$dt); } return $date; - } /** * Parses an iCalendar (rfc5545) formatted date and returns a DateTimeImmutable object. * - * @param string $date + * @param string $date * @param DateTimeZone $tz * * @return DateTimeImmutable */ - static function parseDate($date, DateTimeZone $tz = null) { - + public static function parseDate($date, DateTimeZone $tz = null) + { // Format is YYYYMMDD $result = preg_match('/^([0-9]{4})([0-1][0-9])([0-3][0-9])$/', $date, $matches); if (!$result) { - throw new InvalidDataException('The supplied iCalendar date value is incorrect: ' . $date); + throw new InvalidDataException('The supplied iCalendar date value is incorrect: '.$date); } if (is_null($tz)) { @@ -76,13 +75,12 @@ class DateTimeParser { } try { - $date = new DateTimeImmutable($matches[1] . '-' . $matches[2] . '-' . $matches[3], $tz); + $date = new DateTimeImmutable($matches[1].'-'.$matches[2].'-'.$matches[3], $tz); } catch (\Exception $e) { - throw new InvalidDataException('The supplied iCalendar date value is incorrect: ' . $date); + throw new InvalidDataException('The supplied iCalendar date value is incorrect: '.$date); } return $date; - } /** @@ -92,22 +90,21 @@ class DateTimeParser { * suitable for strtotime or DateTime::modify. * * @param string $duration - * @param bool $asString + * @param bool $asString * * @return DateInterval|string */ - static function parseDuration($duration, $asString = false) { - + public static function parseDuration($duration, $asString = false) + { $result = preg_match('/^(?<plusminus>\+|-)?P((?<week>\d+)W)?((?<day>\d+)D)?(T((?<hour>\d+)H)?((?<minute>\d+)M)?((?<second>\d+)S)?)?$/', $duration, $matches); if (!$result) { - throw new InvalidDataException('The supplied iCalendar duration value is incorrect: ' . $duration); + throw new InvalidDataException('The supplied iCalendar duration value is incorrect: '.$duration); } if (!$asString) { - $invert = false; - if ($matches['plusminus'] === '-') { + if ('-' === $matches['plusminus']) { $invert = true; } @@ -120,7 +117,7 @@ class DateTimeParser { ]; foreach ($parts as $part) { - $matches[$part] = isset($matches[$part]) && $matches[$part] ? (int)$matches[$part] : 0; + $matches[$part] = isset($matches[$part]) && $matches[$part] ? (int) $matches[$part] : 0; } // We need to re-construct the $duration string, because weeks and @@ -133,28 +130,26 @@ class DateTimeParser { } if ($days) { - $duration .= $days . 'D'; + $duration .= $days.'D'; } if ($matches['minute'] || $matches['second'] || $matches['hour']) { - $duration .= 'T'; if ($matches['hour']) { - $duration .= $matches['hour'] . 'H'; + $duration .= $matches['hour'].'H'; } if ($matches['minute']) { - $duration .= $matches['minute'] . 'M'; + $duration .= $matches['minute'].'M'; } if ($matches['second']) { - $duration .= $matches['second'] . 'S'; + $duration .= $matches['second'].'S'; } - } - if ($duration === 'P') { + if ('P' === $duration) { $duration = 'PT0S'; } @@ -165,7 +160,6 @@ class DateTimeParser { } return $iv; - } $parts = [ @@ -180,38 +174,36 @@ class DateTimeParser { foreach ($parts as $part) { if (isset($matches[$part]) && $matches[$part]) { - $newDur .= ' ' . $matches[$part] . ' ' . $part . 's'; + $newDur .= ' '.$matches[$part].' '.$part.'s'; } } - $newDur = ($matches['plusminus'] === '-' ? '-' : '+') . trim($newDur); + $newDur = ('-' === $matches['plusminus'] ? '-' : '+').trim($newDur); - if ($newDur === '+') { + if ('+' === $newDur) { $newDur = '+0 seconds'; - }; + } return $newDur; - } /** * Parses either a Date or DateTime, or Duration value. * - * @param string $date + * @param string $date * @param DateTimeZone|string $referenceTz * * @return DateTimeImmutable|DateInterval */ - static function parse($date, $referenceTz = null) { - - if ($date[0] === 'P' || ($date[0] === '-' && $date[1] === 'P')) { + public static function parse($date, $referenceTz = null) + { + if ('P' === $date[0] || ('-' === $date[0] && 'P' === $date[1])) { return self::parseDuration($date); - } elseif (strlen($date) === 8) { + } elseif (8 === strlen($date)) { return self::parseDate($date, $referenceTz); } else { return self::parseDateTime($date, $referenceTz); } - } /** @@ -270,8 +262,8 @@ class DateTimeParser { * * @return array */ - static function parseVCardDateTime($date) { - + public static function parseVCardDateTime($date) + { $regex = '/^ (?: # date part (?: @@ -296,7 +288,6 @@ class DateTimeParser { $/x'; if (!preg_match($regex, $date, $matches)) { - // Attempting to parse the extended format. $regex = '/^ (?: # date part @@ -321,9 +312,8 @@ class DateTimeParser { $/x'; if (!preg_match($regex, $date, $matches)) { - throw new InvalidDataException('Invalid vCard date-time string: ' . $date); + throw new InvalidDataException('Invalid vCard date-time string: '.$date); } - } $parts = [ 'year', @@ -332,24 +322,21 @@ class DateTimeParser { 'hour', 'minute', 'second', - 'timezone' + 'timezone', ]; $result = []; foreach ($parts as $part) { - if (empty($matches[$part])) { $result[$part] = null; - } elseif ($matches[$part] === '-' || $matches[$part] === '--') { + } elseif ('-' === $matches[$part] || '--' === $matches[$part]) { $result[$part] = null; } else { $result[$part] = $matches[$part]; } - } return $result; - } /** @@ -394,8 +381,8 @@ class DateTimeParser { * * @return array */ - static function parseVCardTime($date) { - + public static function parseVCardTime($date) + { $regex = '/^ (?<hour> [0-9]{2} | -) (?<minute> [0-9]{2} | -)? @@ -409,9 +396,7 @@ class DateTimeParser { )? $/x'; - if (!preg_match($regex, $date, $matches)) { - // Attempting to parse the extended format. $regex = '/^ (?: (?<hour> [0-9]{2}) : | -) @@ -427,32 +412,28 @@ class DateTimeParser { $/x'; if (!preg_match($regex, $date, $matches)) { - throw new InvalidDataException('Invalid vCard time string: ' . $date); + throw new InvalidDataException('Invalid vCard time string: '.$date); } - } $parts = [ 'hour', 'minute', 'second', - 'timezone' + 'timezone', ]; $result = []; foreach ($parts as $part) { - if (empty($matches[$part])) { $result[$part] = null; - } elseif ($matches[$part] === '-') { + } elseif ('-' === $matches[$part]) { $result[$part] = null; } else { $result[$part] = $matches[$part]; } - } return $result; - } /** @@ -506,32 +487,32 @@ class DateTimeParser { * * @return array */ - static function parseVCardDateAndOrTime($date) { - + public static function parseVCardDateAndOrTime($date) + { // \d{8}|\d{4}-\d\d|--\d\d(\d\d)?|---\d\d - $valueDate = '/^(?J)(?:' . - '(?<year>\d{4})(?<month>\d\d)(?<date>\d\d)' . - '|(?<year>\d{4})-(?<month>\d\d)' . - '|--(?<month>\d\d)(?<date>\d\d)?' . - '|---(?<date>\d\d)' . + $valueDate = '/^(?J)(?:'. + '(?<year>\d{4})(?<month>\d\d)(?<date>\d\d)'. + '|(?<year>\d{4})-(?<month>\d\d)'. + '|--(?<month>\d\d)(?<date>\d\d)?'. + '|---(?<date>\d\d)'. ')$/'; // (\d\d(\d\d(\d\d)?)?|-\d\d(\d\d)?|--\d\d)(Z|[+\-]\d\d(\d\d)?)? - $valueTime = '/^(?J)(?:' . - '((?<hour>\d\d)((?<minute>\d\d)(?<second>\d\d)?)?' . - '|-(?<minute>\d\d)(?<second>\d\d)?' . - '|--(?<second>\d\d))' . - '(?<timezone>(Z|[+\-]\d\d(\d\d)?))?' . + $valueTime = '/^(?J)(?:'. + '((?<hour>\d\d)((?<minute>\d\d)(?<second>\d\d)?)?'. + '|-(?<minute>\d\d)(?<second>\d\d)?'. + '|--(?<second>\d\d))'. + '(?<timezone>(Z|[+\-]\d\d(\d\d)?))?'. ')$/'; // (\d{8}|--\d{4}|---\d\d)T\d\d(\d\d(\d\d)?)?(Z|[+\-]\d\d(\d\d?)? - $valueDateTime = '/^(?:' . - '((?<year0>\d{4})(?<month0>\d\d)(?<date0>\d\d)' . - '|--(?<month1>\d\d)(?<date1>\d\d)' . - '|---(?<date2>\d\d))' . - 'T' . - '(?<hour>\d\d)((?<minute>\d\d)(?<second>\d\d)?)?' . - '(?<timezone>(Z|[+\-]\d\d(\d\d?)))?' . + $valueDateTime = '/^(?:'. + '((?<year0>\d{4})(?<month0>\d\d)(?<date0>\d\d)'. + '|--(?<month1>\d\d)(?<date1>\d\d)'. + '|---(?<date2>\d\d))'. + 'T'. + '(?<hour>\d\d)((?<minute>\d\d)(?<second>\d\d)?)?'. + '(?<timezone>(Z|[+\-]\d\d(\d\d?)))?'. ')$/'; // date-and-or-time is date | date-time | time @@ -540,17 +521,17 @@ class DateTimeParser { if (0 === preg_match($valueDate, $date, $matches) && 0 === preg_match($valueDateTime, $date, $matches) && 0 === preg_match($valueTime, $date, $matches)) { - throw new InvalidDataException('Invalid vCard date-time string: ' . $date); + throw new InvalidDataException('Invalid vCard date-time string: '.$date); } $parts = [ - 'year' => null, - 'month' => null, - 'date' => null, - 'hour' => null, - 'minute' => null, - 'second' => null, - 'timezone' => null + 'year' => null, + 'month' => null, + 'date' => null, + 'hour' => null, + 'minute' => null, + 'second' => null, + 'timezone' => null, ]; // The $valueDateTime expression has a bug with (?J) so we simulate it. @@ -575,6 +556,5 @@ class DateTimeParser { unset($parts['year0']); return $parts; - } } diff --git a/vendor/sabre/vobject/lib/Document.php b/vendor/sabre/vobject/lib/Document.php index 03252ab06..0cb2e0978 100644 --- a/vendor/sabre/vobject/lib/Document.php +++ b/vendor/sabre/vobject/lib/Document.php @@ -16,8 +16,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Document extends Component { - +abstract class Document extends Component +{ /** * Unknown document type. */ @@ -55,28 +55,28 @@ abstract class Document extends Component { * * @var string */ - static $defaultName; + public static $defaultName; /** * List of properties, and which classes they map to. * * @var array */ - static $propertyMap = []; + public static $propertyMap = []; /** * List of components, along with which classes they map to. * * @var array */ - static $componentMap = []; + public static $componentMap = []; /** * List of value-types, and which classes they map to. * * @var array */ - static $valueMap = []; + public static $valueMap = []; /** * Creates a new document. @@ -91,20 +91,20 @@ abstract class Document extends Component { * * new Document(array $children = [], $defaults = true); * new Document(string $name, array $children = [], $defaults = true) - * - * @return void */ - function __construct() { - + public function __construct() + { $args = func_get_args(); - if (count($args) === 0 || is_array($args[0])) { - array_unshift($args, $this, static::$defaultName); - call_user_func_array(['parent', '__construct'], $args); + $name = static::$defaultName; + if (0 === count($args) || is_array($args[0])) { + $children = isset($args[0]) ? $args[0] : []; + $defaults = isset($args[1]) ? $args[1] : true; } else { - array_unshift($args, $this); - call_user_func_array(['parent', '__construct'], $args); + $name = $args[0]; + $children = isset($args[1]) ? $args[1] : []; + $defaults = isset($args[2]) ? $args[2] : true; } - + parent::__construct($this, $name, $children, $defaults); } /** @@ -112,10 +112,9 @@ abstract class Document extends Component { * * @return int */ - function getDocumentType() { - + public function getDocumentType() + { return self::UNKNOWN; - } /** @@ -129,18 +128,13 @@ abstract class Document extends Component { * * @return mixed */ - function create($name) { - + public function create($name) + { if (isset(static::$componentMap[strtoupper($name)])) { - return call_user_func_array([$this, 'createComponent'], func_get_args()); - } else { - return call_user_func_array([$this, 'createProperty'], func_get_args()); - } - } /** @@ -158,22 +152,24 @@ abstract class Document extends Component { * ensure that this does not happen, set $defaults to false. * * @param string $name - * @param array $children - * @param bool $defaults + * @param array $children + * @param bool $defaults * * @return Component */ - function createComponent($name, array $children = null, $defaults = true) { - + public function createComponent($name, array $children = null, $defaults = true) + { $name = strtoupper($name); $class = 'Sabre\\VObject\\Component'; if (isset(static::$componentMap[$name])) { $class = static::$componentMap[$name]; } - if (is_null($children)) $children = []; - return new $class($this, $name, $children, $defaults); + if (is_null($children)) { + $children = []; + } + return new $class($this, $name, $children, $defaults); } /** @@ -187,16 +183,16 @@ abstract class Document extends Component { * Parameter objects. * * @param string $name - * @param mixed $value - * @param array $parameters - * @param string $valueType Force a specific valuetype, such as URI or TEXT + * @param mixed $value + * @param array $parameters + * @param string $valueType Force a specific valuetype, such as URI or TEXT * * @return Property */ - function createProperty($name, $value = null, array $parameters = null, $valueType = null) { - + public function createProperty($name, $value = null, array $parameters = null, $valueType = null) + { // If there's a . in the name, it means it's prefixed by a groupname. - if (($i = strpos($name, '.')) !== false) { + if (false !== ($i = strpos($name, '.'))) { $group = substr($name, 0, $i); $name = strtoupper(substr($name, $i + 1)); } else { @@ -217,17 +213,17 @@ abstract class Document extends Component { if (isset($parameters['VALUE'])) { $class = $this->getClassNameForPropertyValue($parameters['VALUE']); if (is_null($class)) { - throw new InvalidDataException('Unsupported VALUE parameter for ' . $name . ' property. You supplied "' . $parameters['VALUE'] . '"'); + throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"'); } - } - else { + } else { $class = $this->getClassNameForPropertyName($name); } } - if (is_null($parameters)) $parameters = []; + if (is_null($parameters)) { + $parameters = []; + } return new $class($this, $name, $value, $parameters, $group); - } /** @@ -239,15 +235,15 @@ abstract class Document extends Component { * This method returns null if we don't have a specialized class. * * @param string $valueParam + * * @return string|null */ - function getClassNameForPropertyValue($valueParam) { - + public function getClassNameForPropertyValue($valueParam) + { $valueParam = strtoupper($valueParam); if (isset(static::$valueMap[$valueParam])) { return static::$valueMap[$valueParam]; } - } /** @@ -257,14 +253,12 @@ abstract class Document extends Component { * * @return string */ - function getClassNameForPropertyName($propertyName) { - + public function getClassNameForPropertyName($propertyName) + { if (isset(static::$propertyMap[$propertyName])) { return static::$propertyMap[$propertyName]; } else { return 'Sabre\\VObject\\Property\\Unknown'; } - } - } diff --git a/vendor/sabre/vobject/lib/ElementList.php b/vendor/sabre/vobject/lib/ElementList.php index 959249247..56058cbd5 100644 --- a/vendor/sabre/vobject/lib/ElementList.php +++ b/vendor/sabre/vobject/lib/ElementList.php @@ -15,23 +15,19 @@ use LogicException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ElementList extends ArrayIterator { - - +class ElementList extends ArrayIterator +{ /* {{{ ArrayAccess Interface */ /** * Sets an item through ArrayAccess. * - * @param int $offset + * @param int $offset * @param mixed $value - * - * @return void */ - function offsetSet($offset, $value) { - + public function offsetSet($offset, $value) + { throw new LogicException('You can not add new objects to an ElementList'); - } /** @@ -40,15 +36,11 @@ class ElementList extends ArrayIterator { * This method just forwards the request to the inner iterator * * @param int $offset - * - * @return void */ - function offsetUnset($offset) { - + public function offsetUnset($offset) + { throw new LogicException('You can not remove objects from an ElementList'); - } /* }}} */ - } diff --git a/vendor/sabre/vobject/lib/EofException.php b/vendor/sabre/vobject/lib/EofException.php index e9bd55878..837af7eb7 100644 --- a/vendor/sabre/vobject/lib/EofException.php +++ b/vendor/sabre/vobject/lib/EofException.php @@ -10,6 +10,6 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class EofException extends ParseException { - +class EofException extends ParseException +{ } diff --git a/vendor/sabre/vobject/lib/FreeBusyData.php b/vendor/sabre/vobject/lib/FreeBusyData.php index 0a6c72bb2..d05dfc799 100644 --- a/vendor/sabre/vobject/lib/FreeBusyData.php +++ b/vendor/sabre/vobject/lib/FreeBusyData.php @@ -9,17 +9,17 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FreeBusyData { - +class FreeBusyData +{ /** - * Start timestamp + * Start timestamp. * * @var int */ protected $start; /** - * End timestamp + * End timestamp. * * @var int */ @@ -32,35 +32,31 @@ class FreeBusyData { */ protected $data; - function __construct($start, $end) { - + public function __construct($start, $end) + { $this->start = $start; $this->end = $end; $this->data = []; $this->data[] = [ 'start' => $this->start, - 'end' => $this->end, - 'type' => 'FREE', + 'end' => $this->end, + 'type' => 'FREE', ]; - } /** * Adds free or busytime to the data. * - * @param int $start - * @param int $end - * @param string $type FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE - * @return void + * @param int $start + * @param int $end + * @param string $type FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE */ - function add($start, $end, $type) { - + public function add($start, $end, $type) + { if ($start > $this->end || $end < $this->start) { - // This new data is outside our timerange. return; - } if ($start < $this->start) { @@ -75,7 +71,7 @@ class FreeBusyData { // Finding out where we need to insert the new item. $currentIndex = 0; while ($start > $this->data[$currentIndex]['end']) { - $currentIndex++; + ++$currentIndex; } // The standard insertion point will be one _after_ the first @@ -84,14 +80,14 @@ class FreeBusyData { $newItem = [ 'start' => $start, - 'end' => $end, - 'type' => $type, + 'end' => $end, + 'type' => $type, ]; $preceedingItem = $this->data[$insertStartIndex - 1]; if ($this->data[$insertStartIndex - 1]['start'] === $start) { // The old item starts at the exact same point as the new item. - $insertStartIndex--; + --$insertStartIndex; } // Now we know where to insert the item, we need to know where it @@ -105,32 +101,32 @@ class FreeBusyData { } while ($end > $this->data[$currentIndex]['end']) { - - $currentIndex++; - + ++$currentIndex; } // What we are about to insert into the array $newItems = [ - $newItem + $newItem, ]; // This is the amount of items that are completely overwritten by the // new item. $itemsToDelete = $currentIndex - $insertStartIndex; - if ($this->data[$currentIndex]['end'] <= $end) $itemsToDelete++; + if ($this->data[$currentIndex]['end'] <= $end) { + ++$itemsToDelete; + } // If itemsToDelete was -1, it means that the newly inserted item is // actually sitting inside an existing one. This means we need to split // the item at the current position in two and insert the new item in // between. - if ($itemsToDelete === -1) { + if (-1 === $itemsToDelete) { $itemsToDelete = 0; if ($newItem['end'] < $preceedingItem['end']) { $newItems[] = [ 'start' => $newItem['end'] + 1, - 'end' => $preceedingItem['end'], - 'type' => $preceedingItem['type'] + 'end' => $preceedingItem['end'], + 'type' => $preceedingItem['type'], ]; } } @@ -155,8 +151,8 @@ class FreeBusyData { // merge them into one item. if ($this->data[$insertStartIndex - 1]['type'] === $this->data[$insertStartIndex]['type']) { $doMerge = true; - $mergeOffset--; - $mergeDelete++; + --$mergeOffset; + ++$mergeDelete; $mergeItem['start'] = $this->data[$insertStartIndex - 1]['start']; } } @@ -168,10 +164,9 @@ class FreeBusyData { // merge them into one item. if ($this->data[$insertStartIndex + 1]['type'] === $this->data[$insertStartIndex]['type']) { $doMerge = true; - $mergeDelete++; + ++$mergeDelete; $mergeItem['end'] = $this->data[$insertStartIndex + 1]['end']; } - } if ($doMerge) { array_splice( @@ -181,13 +176,10 @@ class FreeBusyData { [$mergeItem] ); } - } - function getData() { - + public function getData() + { return $this->data; - } - } diff --git a/vendor/sabre/vobject/lib/FreeBusyGenerator.php b/vendor/sabre/vobject/lib/FreeBusyGenerator.php index e30b136c4..adb214c08 100644 --- a/vendor/sabre/vobject/lib/FreeBusyGenerator.php +++ b/vendor/sabre/vobject/lib/FreeBusyGenerator.php @@ -23,8 +23,8 @@ use Sabre\VObject\Recur\NoInstancesException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FreeBusyGenerator { - +class FreeBusyGenerator +{ /** * Input objects. * @@ -71,7 +71,7 @@ class FreeBusyGenerator { /** * A VAVAILABILITY document. * - * If this is set, it's information will be included when calculating + * If this is set, its information will be included when calculating * freebusy time. * * @var Document @@ -86,11 +86,11 @@ class FreeBusyGenerator { * * @param DateTimeInterface $start * @param DateTimeInterface $end - * @param mixed $objects - * @param DateTimeZone $timeZone + * @param mixed $objects + * @param DateTimeZone $timeZone */ - function __construct(DateTimeInterface $start = null, DateTimeInterface $end = null, $objects = null, DateTimeZone $timeZone = null) { - + public function __construct(DateTimeInterface $start = null, DateTimeInterface $end = null, $objects = null, DateTimeZone $timeZone = null) + { $this->setTimeRange($start, $end); if ($objects) { @@ -100,7 +100,6 @@ class FreeBusyGenerator { $timeZone = new DateTimeZone('UTC'); } $this->setTimeZone($timeZone); - } /** @@ -112,24 +111,20 @@ class FreeBusyGenerator { * The VFREEBUSY object will be automatically added though. * * @param Document $vcalendar - * @return void */ - function setBaseObject(Document $vcalendar) { - + public function setBaseObject(Document $vcalendar) + { $this->baseObject = $vcalendar; - } /** * Sets a VAVAILABILITY document. * * @param Document $vcalendar - * @return void */ - function setVAvailability(Document $vcalendar) { - + public function setVAvailability(Document $vcalendar) + { $this->vavailability = $vcalendar; - } /** @@ -140,18 +135,15 @@ class FreeBusyGenerator { * It's also possible to specify multiple objects as an array. * * @param mixed $objects - * - * @return void */ - function setObjects($objects) { - + public function setObjects($objects) + { if (!is_array($objects)) { $objects = [$objects]; } $this->objects = []; foreach ($objects as $object) { - if (is_string($object) || is_resource($object)) { $this->objects[] = Reader::read($object); } elseif ($object instanceof Component) { @@ -159,9 +151,7 @@ class FreeBusyGenerator { } else { throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component arguments to setObjects'); } - } - } /** @@ -171,11 +161,9 @@ class FreeBusyGenerator { * * @param DateTimeInterface $start * @param DateTimeInterface $end - * - * @return void */ - function setTimeRange(DateTimeInterface $start = null, DateTimeInterface $end = null) { - + public function setTimeRange(DateTimeInterface $start = null, DateTimeInterface $end = null) + { if (!$start) { $start = new DateTimeImmutable(Settings::$minDate); } @@ -184,20 +172,16 @@ class FreeBusyGenerator { } $this->start = $start; $this->end = $end; - } /** * Sets the reference timezone for floating times. * * @param DateTimeZone $timeZone - * - * @return void */ - function setTimeZone(DateTimeZone $timeZone) { - + public function setTimeZone(DateTimeZone $timeZone) + { $this->timeZone = $timeZone; - } /** @@ -206,23 +190,19 @@ class FreeBusyGenerator { * * @return Component */ - function getResult() { - + public function getResult() + { $fbData = new FreeBusyData( $this->start->getTimeStamp(), $this->end->getTimeStamp() ); if ($this->vavailability) { - $this->calculateAvailability($fbData, $this->vavailability); - } $this->calculateBusy($fbData, $this->objects); return $this->generateFreeBusyCalendar($fbData); - - } /** @@ -230,29 +210,30 @@ class FreeBusyGenerator { * available times. * * @param FreeBusyData $fbData - * @param VCalendar $vavailability - * @return void + * @param VCalendar $vavailability */ - protected function calculateAvailability(FreeBusyData $fbData, VCalendar $vavailability) { - + protected function calculateAvailability(FreeBusyData $fbData, VCalendar $vavailability) + { $vavailComps = iterator_to_array($vavailability->VAVAILABILITY); usort( $vavailComps, - function($a, $b) { - + function ($a, $b) { // We need to order the components by priority. Priority 1 // comes first, up until priority 9. Priority 0 comes after // priority 9. No priority implies priority 0. // // Yes, I'm serious. - $priorityA = isset($a->PRIORITY) ? (int)$a->PRIORITY->getValue() : 0; - $priorityB = isset($b->PRIORITY) ? (int)$b->PRIORITY->getValue() : 0; + $priorityA = isset($a->PRIORITY) ? (int) $a->PRIORITY->getValue() : 0; + $priorityB = isset($b->PRIORITY) ? (int) $b->PRIORITY->getValue() : 0; - if ($priorityA === 0) $priorityA = 10; - if ($priorityB === 0) $priorityB = 10; + if (0 === $priorityA) { + $priorityA = 10; + } + if (0 === $priorityB) { + $priorityB = 10; + } return $priorityA - $priorityB; - } ); @@ -267,7 +248,6 @@ class FreeBusyGenerator { $new = []; foreach ($old as $vavail) { - list($compStart, $compEnd) = $vavail->getEffectiveStartEnd(); // We don't care about datetimes that are earlier or later than the @@ -288,24 +268,19 @@ class FreeBusyGenerator { // Going through our existing list of components to see if there's // a higher priority component that already fully covers this one. foreach ($new as $higherVavail) { - list($higherStart, $higherEnd) = $higherVavail->getEffectiveStartEnd(); if ( (is_null($higherStart) || $higherStart < $compStart) && (is_null($higherEnd) || $higherEnd > $compEnd) ) { - // Component is fully covered by a higher priority // component. We can skip this component. continue 2; - } - } // We're keeping it! $new[] = $vavail; - } // Lastly, we need to traverse the remaining components and fill in the @@ -314,7 +289,6 @@ class FreeBusyGenerator { // We traverse the components in reverse, because we want the higher // priority components to override the lower ones. foreach (array_reverse($new) as $vavail) { - $busyType = isset($vavail->BUSYTYPE) ? strtoupper($vavail->BUSYTYPE) : 'BUSY-UNAVAILABLE'; list($vavailStart, $vavailEnd) = $vavail->getEffectiveStartEnd(); @@ -336,57 +310,53 @@ class FreeBusyGenerator { ); // Looping over the AVAILABLE components. - if (isset($vavail->AVAILABLE)) foreach ($vavail->AVAILABLE as $available) { - - list($availStart, $availEnd) = $available->getEffectiveStartEnd(); - $fbData->add( + if (isset($vavail->AVAILABLE)) { + foreach ($vavail->AVAILABLE as $available) { + list($availStart, $availEnd) = $available->getEffectiveStartEnd(); + $fbData->add( $availStart->getTimeStamp(), $availEnd->getTimeStamp(), 'FREE' ); - if ($available->RRULE) { - // Our favourite thing: recurrence!! + if ($available->RRULE) { + // Our favourite thing: recurrence!! - $rruleIterator = new Recur\RRuleIterator( + $rruleIterator = new Recur\RRuleIterator( $available->RRULE->getValue(), $availStart ); - $rruleIterator->fastForward($vavailStart); + $rruleIterator->fastForward($vavailStart); - $startEndDiff = $availStart->diff($availEnd); + $startEndDiff = $availStart->diff($availEnd); - while ($rruleIterator->valid()) { + while ($rruleIterator->valid()) { + $recurStart = $rruleIterator->current(); + $recurEnd = $recurStart->add($startEndDiff); - $recurStart = $rruleIterator->current(); - $recurEnd = $recurStart->add($startEndDiff); - - if ($recurStart > $vavailEnd) { - // We're beyond the legal timerange. - break; - } + if ($recurStart > $vavailEnd) { + // We're beyond the legal timerange. + break; + } - if ($recurEnd > $vavailEnd) { - // Truncating the end if it exceeds the - // VAVAILABILITY end. - $recurEnd = $vavailEnd; - } + if ($recurEnd > $vavailEnd) { + // Truncating the end if it exceeds the + // VAVAILABILITY end. + $recurEnd = $vavailEnd; + } - $fbData->add( + $fbData->add( $recurStart->getTimeStamp(), $recurEnd->getTimeStamp(), 'FREE' ); - $rruleIterator->next(); - + $rruleIterator->next(); + } } } - } - } - } /** @@ -394,28 +364,25 @@ class FreeBusyGenerator { * times on fbData. * * @param FreeBusyData $fbData - * @param VCalendar[] $objects + * @param VCalendar[] $objects */ - protected function calculateBusy(FreeBusyData $fbData, array $objects) { - + protected function calculateBusy(FreeBusyData $fbData, array $objects) + { foreach ($objects as $key => $object) { - foreach ($object->getBaseComponents() as $component) { - switch ($component->name) { - - case 'VEVENT' : + case 'VEVENT': $FBTYPE = 'BUSY'; - if (isset($component->TRANSP) && (strtoupper($component->TRANSP) === 'TRANSPARENT')) { + if (isset($component->TRANSP) && ('TRANSPARENT' === strtoupper($component->TRANSP))) { break; } if (isset($component->STATUS)) { $status = strtoupper($component->STATUS); - if ($status === 'CANCELLED') { + if ('CANCELLED' === $status) { break; } - if ($status === 'TENTATIVE') { + if ('TENTATIVE' === $status) { $FBTYPE = 'BUSY-TENTATIVE'; } } @@ -424,13 +391,13 @@ class FreeBusyGenerator { if ($component->RRULE) { try { - $iterator = new EventIterator($object, (string)$component->UID, $this->timeZone); + $iterator = new EventIterator($object, (string) $component->UID, $this->timeZone); } catch (NoInstancesException $e) { // This event is recurring, but it doesn't have a single // instance. We are skipping this event from the output // entirely. unset($this->objects[$key]); - continue; + break; } if ($this->start) { @@ -440,7 +407,6 @@ class FreeBusyGenerator { $maxRecurrences = Settings::$maxRecurrences; while ($iterator->valid() && --$maxRecurrences) { - $startTime = $iterator->getDTStart(); if ($this->end && $startTime > $this->end) { break; @@ -451,11 +417,8 @@ class FreeBusyGenerator { ]; $iterator->next(); - } - } else { - $startTime = $component->DTSTART->getDateTime($this->timeZone); if ($this->end && $startTime > $this->end) { break; @@ -464,7 +427,7 @@ class FreeBusyGenerator { if (isset($component->DTEND)) { $endTime = $component->DTEND->getDateTime($this->timeZone); } elseif (isset($component->DURATION)) { - $duration = DateTimeParser::parseDuration((string)$component->DURATION); + $duration = DateTimeParser::parseDuration((string) $component->DURATION); $endTime = clone $startTime; $endTime = $endTime->add($duration); } elseif (!$component->DTSTART->hasTime()) { @@ -476,13 +439,15 @@ class FreeBusyGenerator { } $times[] = [$startTime, $endTime]; - } foreach ($times as $time) { - - if ($this->end && $time[0] > $this->end) break; - if ($this->start && $time[1] < $this->start) break; + if ($this->end && $time[0] > $this->end) { + break; + } + if ($this->start && $time[1] < $this->start) { + break; + } $fbData->add( $time[0]->getTimeStamp(), @@ -492,21 +457,21 @@ class FreeBusyGenerator { } break; - case 'VFREEBUSY' : + case 'VFREEBUSY': foreach ($component->FREEBUSY as $freebusy) { - $fbType = isset($freebusy['FBTYPE']) ? strtoupper($freebusy['FBTYPE']) : 'BUSY'; // Skipping intervals marked as 'free' - if ($fbType === 'FREE') + if ('FREE' === $fbType) { continue; + } $values = explode(',', $freebusy); foreach ($values as $value) { list($startTime, $endTime) = explode('/', $value); $startTime = DateTimeParser::parseDateTime($startTime); - if (substr($endTime, 0, 1) === 'P' || substr($endTime, 0, 2) === '-P') { + if ('P' === substr($endTime, 0, 1) || '-P' === substr($endTime, 0, 2)) { $duration = DateTimeParser::parseDuration($endTime); $endTime = clone $startTime; $endTime = $endTime->add($duration); @@ -514,27 +479,23 @@ class FreeBusyGenerator { $endTime = DateTimeParser::parseDateTime($endTime); } - if ($this->start && $this->start > $endTime) continue; - if ($this->end && $this->end < $startTime) continue; + if ($this->start && $this->start > $endTime) { + continue; + } + if ($this->end && $this->end < $startTime) { + continue; + } $fbData->add( $startTime->getTimeStamp(), $endTime->getTimeStamp(), $fbType ); - } - - } break; - } - - } - } - } /** @@ -543,8 +504,8 @@ class FreeBusyGenerator { * * @return VCalendar */ - protected function generateFreeBusyCalendar(FreeBusyData $fbData) { - + protected function generateFreeBusyCalendar(FreeBusyData $fbData) + { if ($this->baseObject) { $calendar = $this->baseObject; } else { @@ -571,34 +532,29 @@ class FreeBusyGenerator { $vfreebusy->add($dtstamp); foreach ($fbData->getData() as $busyTime) { - $busyType = strtoupper($busyTime['type']); // Ignoring all the FREE parts, because those are already assumed. - if ($busyType === 'FREE') { + if ('FREE' === $busyType) { continue; } - $busyTime[0] = new \DateTimeImmutable('@' . $busyTime['start'], $tz); - $busyTime[1] = new \DateTimeImmutable('@' . $busyTime['end'], $tz); + $busyTime[0] = new \DateTimeImmutable('@'.$busyTime['start'], $tz); + $busyTime[1] = new \DateTimeImmutable('@'.$busyTime['end'], $tz); $prop = $calendar->createProperty( 'FREEBUSY', - $busyTime[0]->format('Ymd\\THis\\Z') . '/' . $busyTime[1]->format('Ymd\\THis\\Z') + $busyTime[0]->format('Ymd\\THis\\Z').'/'.$busyTime[1]->format('Ymd\\THis\\Z') ); // Only setting FBTYPE if it's not BUSY, because BUSY is the // default anyway. - if ($busyType !== 'BUSY') { + if ('BUSY' !== $busyType) { $prop['FBTYPE'] = $busyType; } $vfreebusy->add($prop); - } return $calendar; - - } - } diff --git a/vendor/sabre/vobject/lib/ITip/Broker.php b/vendor/sabre/vobject/lib/ITip/Broker.php index b954cdc8d..b1cfee367 100644 --- a/vendor/sabre/vobject/lib/ITip/Broker.php +++ b/vendor/sabre/vobject/lib/ITip/Broker.php @@ -35,8 +35,8 @@ use Sabre\VObject\Recur\EventIterator; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Broker { - +class Broker +{ /** * This setting determines whether the rules for the SCHEDULE-AGENT * parameter should be followed. @@ -104,37 +104,34 @@ class Broker { * * If the iTip message was not supported, we will always return false. * - * @param Message $itipMessage + * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null */ - function processMessage(Message $itipMessage, VCalendar $existingObject = null) { - + public function processMessage(Message $itipMessage, VCalendar $existingObject = null) + { // We only support events at the moment. - if ($itipMessage->component !== 'VEVENT') { + if ('VEVENT' !== $itipMessage->component) { return false; } switch ($itipMessage->method) { - - case 'REQUEST' : + case 'REQUEST': return $this->processMessageRequest($itipMessage, $existingObject); - case 'CANCEL' : + case 'CANCEL': return $this->processMessageCancel($itipMessage, $existingObject); - case 'REPLY' : + case 'REPLY': return $this->processMessageReply($itipMessage, $existingObject); - default : + default: // Unsupported iTip message return; - } return $existingObject; - } /** @@ -161,13 +158,13 @@ class Broker { * organizer gets the 'declined' message. * * @param VCalendar|string $calendar - * @param string|array $userHref + * @param string|array $userHref * @param VCalendar|string $oldCalendar * * @return array */ - function parseEvent($calendar = null, $userHref, $oldCalendar = null) { - + public function parseEvent($calendar = null, $userHref, $oldCalendar = null) + { if ($oldCalendar) { if (is_string($oldCalendar)) { $oldCalendar = Reader::read($oldCalendar); @@ -180,16 +177,15 @@ class Broker { $oldEventInfo = $this->parseEventInfo($oldCalendar); } else { $oldEventInfo = [ - 'organizer' => null, + 'organizer' => null, 'significantChangeHash' => '', - 'attendees' => [], + 'attendees' => [], ]; } - $userHref = (array)$userHref; + $userHref = (array) $userHref; if (!is_null($calendar)) { - if (is_string($calendar)) { $calendar = Reader::read($calendar); } @@ -217,7 +213,6 @@ class Broker { $eventInfo['organizer'] = $oldEventInfo['organizer']; $eventInfo['organizerName'] = $oldEventInfo['organizerName']; } - } else { // The calendar object got deleted, we need to process this as a // cancellation / decline. @@ -233,19 +228,17 @@ class Broker { $eventInfo['attendees'] = []; // Increasing the sequence, but only if the organizer deleted // the event. - $eventInfo['sequence']++; + ++$eventInfo['sequence']; } else { // This is an attendee deleting the event. foreach ($eventInfo['attendees'] as $key => $attendee) { if (in_array($attendee['href'], $userHref)) { - $eventInfo['attendees'][$key]['instances'] = ['master' => - ['id' => 'master', 'partstat' => 'DECLINED'] + $eventInfo['attendees'][$key]['instances'] = ['master' => ['id' => 'master', 'partstat' => 'DECLINED'], ]; } } } $baseCalendar = $oldCalendar; - } if (in_array($eventInfo['organizer'], $userHref)) { @@ -260,8 +253,8 @@ class Broker { } } } - return []; + return []; } /** @@ -271,13 +264,13 @@ class Broker { * invite, or an update to an existing one. * * - * @param Message $itipMessage + * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null */ - protected function processMessageRequest(Message $itipMessage, VCalendar $existingObject = null) { - + protected function processMessageRequest(Message $itipMessage, VCalendar $existingObject = null) + { if (!$existingObject) { // This is a new invite, and we're just going to copy over // all the components from the invite. @@ -296,8 +289,8 @@ class Broker { $existingObject->add(clone $component); } } - return $existingObject; + return $existingObject; } /** @@ -307,13 +300,13 @@ class Broker { * attendee got removed from an event, or an event got cancelled * altogether. * - * @param Message $itipMessage + * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null */ - protected function processMessageCancel(Message $itipMessage, VCalendar $existingObject = null) { - + protected function processMessageCancel(Message $itipMessage, VCalendar $existingObject = null) + { if (!$existingObject) { // The event didn't exist in the first place, so we're just // ignoring this message. @@ -323,8 +316,8 @@ class Broker { $vevent->SEQUENCE = $itipMessage->sequence; } } - return $existingObject; + return $existingObject; } /** @@ -333,13 +326,13 @@ class Broker { * The message is a reply. This is for example an attendee telling * an organizer he accepted the invite, or declined it. * - * @param Message $itipMessage + * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null */ - protected function processMessageReply(Message $itipMessage, VCalendar $existingObject = null) { - + protected function processMessageReply(Message $itipMessage, VCalendar $existingObject = null) + { // A reply can only be processed based on an existing object. // If the object is not available, the reply is ignored. if (!$existingObject) { @@ -364,7 +357,7 @@ class Broker { $masterObject = null; foreach ($existingObject->VEVENT as $vevent) { $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; - if ($recurId === 'master') { + if ('master' === $recurId) { $masterObject = $vevent; } if (isset($instances[$recurId])) { @@ -386,9 +379,11 @@ class Broker { // Adding a new attendee. The iTip documentation calls this // a party crasher. $attendee = $vevent->add('ATTENDEE', $itipMessage->sender, [ - 'PARTSTAT' => $instances[$recurId] + 'PARTSTAT' => $instances[$recurId], ]); - if ($itipMessage->senderName) $attendee['CN'] = $itipMessage->senderName; + if ($itipMessage->senderName) { + $attendee['CN'] = $itipMessage->senderName; + } } unset($instances[$recurId]); } @@ -401,24 +396,23 @@ class Broker { // If we got replies to instances that did not exist in the // original list, it means that new exceptions must be created. foreach ($instances as $recurId => $partstat) { - $recurrenceIterator = new EventIterator($existingObject, $itipMessage->uid); $found = false; $iterations = 1000; do { - $newObject = $recurrenceIterator->getEventObject(); $recurrenceIterator->next(); if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getValue() === $recurId) { $found = true; } - $iterations--; - + --$iterations; } while ($recurrenceIterator->valid() && !$found && $iterations); // Invalid recurrence id. Skipping this object. - if (!$found) continue; + if (!$found) { + continue; + } unset( $newObject->RRULE, @@ -438,17 +432,16 @@ class Broker { if (!$attendeeFound) { // Adding a new attendee $attendee = $newObject->add('ATTENDEE', $itipMessage->sender, [ - 'PARTSTAT' => $partstat + 'PARTSTAT' => $partstat, ]); if ($itipMessage->senderName) { $attendee['CN'] = $itipMessage->senderName; } } $existingObject->add($newObject); - } - return $existingObject; + return $existingObject; } /** @@ -460,22 +453,22 @@ class Broker { * specific messages for these situations. * * @param VCalendar $calendar - * @param array $eventInfo - * @param array $oldEventInfo + * @param array $eventInfo + * @param array $oldEventInfo * * @return array */ - protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, array $oldEventInfo) { - + protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, array $oldEventInfo) + { // Merging attendee lists. $attendees = []; foreach ($oldEventInfo['attendees'] as $attendee) { $attendees[$attendee['href']] = [ - 'href' => $attendee['href'], + 'href' => $attendee['href'], 'oldInstances' => $attendee['instances'], 'newInstances' => [], - 'name' => $attendee['name'], - 'forceSend' => null, + 'name' => $attendee['name'], + 'forceSend' => null, ]; } foreach ($eventInfo['attendees'] as $attendee) { @@ -485,11 +478,11 @@ class Broker { $attendees[$attendee['href']]['forceSend'] = $attendee['forceSend']; } else { $attendees[$attendee['href']] = [ - 'href' => $attendee['href'], + 'href' => $attendee['href'], 'oldInstances' => [], 'newInstances' => $attendee['instances'], - 'name' => $attendee['name'], - 'forceSend' => $attendee['forceSend'], + 'name' => $attendee['name'], + 'forceSend' => $attendee['forceSend'], ]; } } @@ -497,7 +490,6 @@ class Broker { $messages = []; foreach ($attendees as $attendee) { - // An organizer can also be an attendee. We should not generate any // messages for those. if ($attendee['href'] === $eventInfo['organizer']) { @@ -514,7 +506,6 @@ class Broker { $message->recipientName = $attendee['name']; if (!$attendee['newInstances']) { - // If there are no instances the attendee is a part of, it // means the attendee was removed and we need to send him a // CANCEL. @@ -523,8 +514,13 @@ class Broker { // Creating the new iCalendar body. $icalMsg = new VCalendar(); $icalMsg->METHOD = $message->method; + + foreach ($calendar->select('VTIMEZONE') as $timezone) { + $icalMsg->add(clone $timezone); + } + $event = $icalMsg->add('VEVENT', [ - 'UID' => $message->uid, + 'UID' => $message->uid, 'SEQUENCE' => $message->sequence, ]); if (isset($calendar->VEVENT->SUMMARY)) { @@ -537,14 +533,14 @@ class Broker { $event->add(clone $calendar->VEVENT->DURATION); } $org = $event->add('ORGANIZER', $eventInfo['organizer']); - if ($eventInfo['organizerName']) $org['CN'] = $eventInfo['organizerName']; + if ($eventInfo['organizerName']) { + $org['CN'] = $eventInfo['organizerName']; + } $event->add('ATTENDEE', $attendee['href'], [ 'CN' => $attendee['name'], ]); $message->significantChange = true; - } else { - // The attendee gets the updated event body $message->method = 'REQUEST'; @@ -565,15 +561,13 @@ class Broker { // difference in instances that the attendee is invited to. $message->significantChange = - $attendee['forceSend'] === 'REQUEST' || + 'REQUEST' === $attendee['forceSend'] || array_keys($attendee['oldInstances']) != array_keys($attendee['newInstances']) || $oldEventInfo['significantChangeHash'] !== $eventInfo['significantChangeHash']; foreach ($attendee['newInstances'] as $instanceId => $instanceInfo) { - $currentEvent = clone $eventInfo['instances'][$instanceId]; - if ($instanceId === 'master') { - + if ('master' === $instanceId) { // We need to find a list of events that the attendee // is not a part of to add to the list of exceptions. $exceptions = []; @@ -610,24 +604,18 @@ class Broker { if (!isset($attendee['PARTSTAT'])) { $attendee['PARTSTAT'] = 'NEEDS-ACTION'; } - } - } $icalMsg->add($currentEvent); - } - } $message->message = $icalMsg; $messages[] = $message; - } return $messages; - } /** @@ -636,21 +624,21 @@ class Broker { * This function figures out if we need to send a reply to an organizer. * * @param VCalendar $calendar - * @param array $eventInfo - * @param array $oldEventInfo - * @param string $attendee + * @param array $eventInfo + * @param array $oldEventInfo + * @param string $attendee * * @return Message[] */ - protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, array $oldEventInfo, $attendee) { - - if ($this->scheduleAgentServerRules && $eventInfo['organizerScheduleAgent'] === 'CLIENT') { + protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, array $oldEventInfo, $attendee) + { + if ($this->scheduleAgentServerRules && 'CLIENT' === $eventInfo['organizerScheduleAgent']) { return []; } // Don't bother generating messages for events that have already been // cancelled. - if ($eventInfo['status'] === 'CANCELLED') { + if ('CANCELLED' === $eventInfo['status']) { return []; } @@ -660,26 +648,22 @@ class Broker { $instances = []; foreach ($oldInstances as $instance) { - $instances[$instance['id']] = [ - 'id' => $instance['id'], + 'id' => $instance['id'], 'oldstatus' => $instance['partstat'], 'newstatus' => null, ]; - } foreach ($eventInfo['attendees'][$attendee]['instances'] as $instance) { - if (isset($instances[$instance['id']])) { $instances[$instance['id']]['newstatus'] = $instance['partstat']; } else { $instances[$instance['id']] = [ - 'id' => $instance['id'], + 'id' => $instance['id'], 'oldstatus' => null, 'newstatus' => $instance['partstat'], ]; } - } // We need to also look for differences in EXDATE. If there are new @@ -687,33 +671,29 @@ class Broker { // event, which means we need to send DECLINED specifically for those // instances. // We only need to do that though, if the master event is not declined. - if (isset($instances['master']) && $instances['master']['newstatus'] !== 'DECLINED') { + if (isset($instances['master']) && 'DECLINED' !== $instances['master']['newstatus']) { foreach ($eventInfo['exdate'] as $exDate) { - if (!in_array($exDate, $oldEventInfo['exdate'])) { if (isset($instances[$exDate])) { $instances[$exDate]['newstatus'] = 'DECLINED'; } else { $instances[$exDate] = [ - 'id' => $exDate, + 'id' => $exDate, 'oldstatus' => null, 'newstatus' => 'DECLINED', ]; } } - } } // Gathering a few extra properties for each instance. foreach ($instances as $recurId => $instanceInfo) { - if (isset($eventInfo['instances'][$recurId])) { $instances[$recurId]['dtstart'] = clone $eventInfo['instances'][$recurId]->DTSTART; } else { $instances[$recurId]['dtstart'] = $recurId; } - } $message = new Message(); @@ -732,14 +712,13 @@ class Broker { $hasReply = false; foreach ($instances as $instance) { - - if ($instance['oldstatus'] == $instance['newstatus'] && $eventInfo['organizerForceSend'] !== 'REPLY') { + if ($instance['oldstatus'] == $instance['newstatus'] && 'REPLY' !== $eventInfo['organizerForceSend']) { // Skip continue; } $event = $icalMsg->add('VEVENT', [ - 'UID' => $message->uid, + 'UID' => $message->uid, 'SEQUENCE' => $message->sequence, ]); $summary = isset($calendar->VEVENT->SUMMARY) ? $calendar->VEVENT->SUMMARY->getValue() : ''; @@ -773,7 +752,7 @@ class Broker { $event->add('SUMMARY', $summary); } } - if ($instance['id'] !== 'master') { + if ('master' !== $instance['id']) { $dt = DateTimeParser::parse($instance['id'], $eventInfo['timezone']); // Treat is as a DATE field if (strlen($instance['id']) <= 8) { @@ -787,22 +766,21 @@ class Broker { $organizer['CN'] = $message->recipientName; } $attendee = $event->add('ATTENDEE', $message->sender, [ - 'PARTSTAT' => $instance['newstatus'] + 'PARTSTAT' => $instance['newstatus'], ]); if ($message->senderName) { $attendee['CN'] = $message->senderName; } $hasReply = true; - } if ($hasReply) { $message->message = $icalMsg; + return [$message]; } else { return []; } - } /** @@ -824,12 +802,13 @@ class Broker { * based on. * 11. significantChangeHash * 12. status + * * @param VCalendar $calendar * * @return array */ - protected function parseEventInfo(VCalendar $calendar = null) { - + protected function parseEventInfo(VCalendar $calendar = null) + { $uid = null; $organizer = null; $organizerName = null; @@ -868,7 +847,7 @@ class Broker { $organizer = $vevent->ORGANIZER->getNormalizedValue(); $organizerName = isset($vevent->ORGANIZER['CN']) ? $vevent->ORGANIZER['CN'] : null; } else { - if ($organizer !== $vevent->ORGANIZER->getNormalizedValue()) { + if (strtoupper($organizer) !== strtoupper($vevent->ORGANIZER->getNormalizedValue())) { throw new SameOrganizerForAllComponentsException('Every instance of the event must have the same organizer.'); } } @@ -878,7 +857,7 @@ class Broker { null; $organizerScheduleAgent = isset($vevent->ORGANIZER['SCHEDULE-AGENT']) ? - strtoupper((string)$vevent->ORGANIZER['SCHEDULE-AGENT']) : + strtoupper((string) $vevent->ORGANIZER['SCHEDULE-AGENT']) : 'SERVER'; } if (is_null($sequence) && isset($vevent->SEQUENCE)) { @@ -894,7 +873,7 @@ class Broker { foreach ($vevent->select('RRULE') as $rr) { foreach ($rr->getParts() as $key => $val) { // ignore default values (https://github.com/sabre-io/vobject/issues/126) - if ($key === 'INTERVAL' && $val == 1) { + if ('INTERVAL' === $key && 1 == $val) { continue; } if (is_array($val)) { @@ -911,7 +890,7 @@ class Broker { $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; if (is_null($timezone)) { - if ($recurId === 'master') { + if ('master' === $recurId) { $timezone = $vevent->DTSTART->getDateTime()->getTimeZone(); } else { $timezone = $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimeZone(); @@ -919,10 +898,9 @@ class Broker { } if (isset($vevent->ATTENDEE)) { foreach ($vevent->ATTENDEE as $attendee) { - if ($this->scheduleAgentServerRules && isset($attendee['SCHEDULE-AGENT']) && - strtoupper($attendee['SCHEDULE-AGENT']->getValue()) === 'CLIENT' + 'CLIENT' === strtoupper($attendee['SCHEDULE-AGENT']->getValue()) ) { continue; } @@ -936,45 +914,42 @@ class Broker { strtoupper($attendee['SCHEDULE-FORCE-SEND']) : null; - if (isset($attendees[$attendee->getNormalizedValue()])) { $attendees[$attendee->getNormalizedValue()]['instances'][$recurId] = [ - 'id' => $recurId, - 'partstat' => $partStat, + 'id' => $recurId, + 'partstat' => $partStat, 'forceSend' => $forceSend, ]; } else { $attendees[$attendee->getNormalizedValue()] = [ - 'href' => $attendee->getNormalizedValue(), + 'href' => $attendee->getNormalizedValue(), 'instances' => [ $recurId => [ - 'id' => $recurId, + 'id' => $recurId, 'partstat' => $partStat, ], ], - 'name' => isset($attendee['CN']) ? (string)$attendee['CN'] : null, + 'name' => isset($attendee['CN']) ? (string) $attendee['CN'] : null, 'forceSend' => $forceSend, ]; } - } $instances[$recurId] = $vevent; - } foreach ($this->significantChangeProperties as $prop) { if (isset($vevent->$prop)) { $propertyValues = $vevent->select($prop); - $significantChangeHash .= $prop . ':'; + $significantChangeHash .= $prop.':'; - if ($prop === 'EXDATE') { - $significantChangeHash .= implode(',', $exdate) . ';'; - } elseif ($prop === 'RRULE') { - $significantChangeHash .= implode(',', $rrule) . ';'; + if ('EXDATE' === $prop) { + $significantChangeHash .= implode(',', $exdate).';'; + } elseif ('RRULE' === $prop) { + $significantChangeHash .= implode(',', $rrule).';'; } else { foreach ($propertyValues as $val) { - $significantChangeHash .= $val->getValue() . ';'; + $significantChangeHash .= $val->getValue().';'; } } } @@ -996,7 +971,5 @@ class Broker { 'significantChangeHash', 'status' ); - } - } diff --git a/vendor/sabre/vobject/lib/ITip/ITipException.php b/vendor/sabre/vobject/lib/ITip/ITipException.php index ad5e53ab4..949563614 100644 --- a/vendor/sabre/vobject/lib/ITip/ITipException.php +++ b/vendor/sabre/vobject/lib/ITip/ITipException.php @@ -11,5 +11,6 @@ use Exception; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ITipException extends Exception { +class ITipException extends Exception +{ } diff --git a/vendor/sabre/vobject/lib/ITip/Message.php b/vendor/sabre/vobject/lib/ITip/Message.php index bebe2e4fc..43536f172 100644 --- a/vendor/sabre/vobject/lib/ITip/Message.php +++ b/vendor/sabre/vobject/lib/ITip/Message.php @@ -14,8 +14,8 @@ namespace Sabre\VObject\ITip; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Message { - +class Message +{ /** * The object's UID. * @@ -123,19 +123,14 @@ class Message { * * @return mixed bool|string */ - function getScheduleStatus() { - + public function getScheduleStatus() + { if (!$this->scheduleStatus) { - return false; - } else { - list($scheduleStatus) = explode(';', $this->scheduleStatus); - return $scheduleStatus; + return $scheduleStatus; } - } - } diff --git a/vendor/sabre/vobject/lib/ITip/SameOrganizerForAllComponentsException.php b/vendor/sabre/vobject/lib/ITip/SameOrganizerForAllComponentsException.php index 423b39831..4c48625be 100644 --- a/vendor/sabre/vobject/lib/ITip/SameOrganizerForAllComponentsException.php +++ b/vendor/sabre/vobject/lib/ITip/SameOrganizerForAllComponentsException.php @@ -13,6 +13,6 @@ namespace Sabre\VObject\ITip; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SameOrganizerForAllComponentsException extends ITipException { - +class SameOrganizerForAllComponentsException extends ITipException +{ } diff --git a/vendor/sabre/vobject/lib/InvalidDataException.php b/vendor/sabre/vobject/lib/InvalidDataException.php index 50ebc0f49..1d8b67583 100644 --- a/vendor/sabre/vobject/lib/InvalidDataException.php +++ b/vendor/sabre/vobject/lib/InvalidDataException.php @@ -10,5 +10,6 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class InvalidDataException extends \Exception { +class InvalidDataException extends \Exception +{ } diff --git a/vendor/sabre/vobject/lib/Node.php b/vendor/sabre/vobject/lib/Node.php index e2845da75..154a7fac5 100644 --- a/vendor/sabre/vobject/lib/Node.php +++ b/vendor/sabre/vobject/lib/Node.php @@ -11,13 +11,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node - implements \IteratorAggregate, - \ArrayAccess, - \Countable, - \JsonSerializable, - Xml\XmlSerializable { - +abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable, \JsonSerializable, Xml\XmlSerializable +{ /** * The following constants are used by the validate() method. * @@ -70,7 +65,7 @@ abstract class Node * * @return string */ - abstract function serialize(); + abstract public function serialize(); /** * This method returns an array, with the representation as it should be @@ -78,31 +73,26 @@ abstract class Node * * @return array */ - abstract function jsonSerialize(); + abstract public function jsonSerialize(); /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - abstract function xmlSerialize(Xml\Writer $writer); + abstract public function xmlSerialize(Xml\Writer $writer); /** * Call this method on a document if you're done using it. * * It's intended to remove all circular references, so PHP can easily clean * it up. - * - * @return void */ - function destroy() { - + public function destroy() + { $this->parent = null; $this->root = null; - } /* {{{ IteratorAggregator interface */ @@ -112,14 +102,13 @@ abstract class Node * * @return ElementList */ - function getIterator() { - + public function getIterator() + { if (!is_null($this->iterator)) { return $this->iterator; } return new ElementList([$this]); - } /** @@ -128,13 +117,10 @@ abstract class Node * Note that this is not actually part of the iterator interface * * @param ElementList $iterator - * - * @return void */ - function setIterator(ElementList $iterator) { - + public function setIterator(ElementList $iterator) + { $this->iterator = $iterator; - } /** @@ -159,10 +145,9 @@ abstract class Node * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { return []; - } /* }}} */ @@ -174,18 +159,17 @@ abstract class Node * * @return int */ - function count() { - + public function count() + { $it = $this->getIterator(); - return $it->count(); + return $it->count(); } /* }}} */ /* {{{ ArrayAccess Interface */ - /** * Checks if an item exists through ArrayAccess. * @@ -195,11 +179,11 @@ abstract class Node * * @return bool */ - function offsetExists($offset) { - + public function offsetExists($offset) + { $iterator = $this->getIterator(); - return $iterator->offsetExists($offset); + return $iterator->offsetExists($offset); } /** @@ -211,11 +195,11 @@ abstract class Node * * @return mixed */ - function offsetGet($offset) { - + public function offsetGet($offset) + { $iterator = $this->getIterator(); - return $iterator->offsetGet($offset); + return $iterator->offsetGet($offset); } /** @@ -223,21 +207,20 @@ abstract class Node * * This method just forwards the request to the inner iterator * - * @param int $offset + * @param int $offset * @param mixed $value - * - * @return void */ - function offsetSet($offset, $value) { - + public function offsetSet($offset, $value) + { $iterator = $this->getIterator(); $iterator->offsetSet($offset, $value); - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart // // This method always throws an exception, so we ignore the closing // brace } + // @codeCoverageIgnoreEnd /** @@ -246,19 +229,18 @@ abstract class Node * This method just forwards the request to the inner iterator * * @param int $offset - * - * @return void */ - function offsetUnset($offset) { - + public function offsetUnset($offset) + { $iterator = $this->getIterator(); $iterator->offsetUnset($offset); - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart // // This method always throws an exception, so we ignore the closing // brace } + // @codeCoverageIgnoreEnd /* }}} */ diff --git a/vendor/sabre/vobject/lib/PHPUnitAssertions.php b/vendor/sabre/vobject/lib/PHPUnitAssertions.php index 87ec75e8f..d77e4b1ed 100644 --- a/vendor/sabre/vobject/lib/PHPUnitAssertions.php +++ b/vendor/sabre/vobject/lib/PHPUnitAssertions.php @@ -3,7 +3,7 @@ namespace Sabre\VObject; /** - * PHPUnit Assertions + * PHPUnit Assertions. * * This trait can be added to your unittest to make it easier to test iCalendar * and/or vCards. @@ -12,8 +12,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -trait PHPUnitAssertions { - +trait PHPUnitAssertions +{ /** * This method tests wether two vcards or icalendar objects are * semantically identical. @@ -30,13 +30,12 @@ trait PHPUnitAssertions { * * @param resource|string|Component $expected * @param resource|string|Component $actual - * @param string $message + * @param string $message */ - function assertVObjectEqualsVObject($expected, $actual, $message = '') { - + public function assertVObjectEqualsVObject($expected, $actual, $message = '') + { $self = $this; - $getObj = function($input) use ($self) { - + $getObj = function ($input) use ($self) { if (is_resource($input)) { $input = stream_get_contents($input); } @@ -47,11 +46,11 @@ trait PHPUnitAssertions { $this->fail('Input must be a string, stream or VObject component'); } unset($input->PRODID); - if ($input instanceof Component\VCalendar && (string)$input->CALSCALE === 'GREGORIAN') { + if ($input instanceof Component\VCalendar && 'GREGORIAN' === (string) $input->CALSCALE) { unset($input->CALSCALE); } - return $input; + return $input; }; $expected = $getObj($expected)->serialize(); @@ -61,13 +60,11 @@ trait PHPUnitAssertions { preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\r$|m', $expected, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - $actual = preg_replace( - '|^' . preg_quote($match[1], '|') . ':(.*)\r$|m', - $match[1] . ':**ANY**' . "\r", + '|^'.preg_quote($match[1], '|').':(.*)\r$|m', + $match[1].':**ANY**'."\r", $actual ); - } $this->assertEquals( @@ -75,8 +72,5 @@ trait PHPUnitAssertions { $actual, $message ); - } - - } diff --git a/vendor/sabre/vobject/lib/Parameter.php b/vendor/sabre/vobject/lib/Parameter.php index a99a33eec..2c9a8e7fd 100644 --- a/vendor/sabre/vobject/lib/Parameter.php +++ b/vendor/sabre/vobject/lib/Parameter.php @@ -17,8 +17,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Parameter extends Node { - +class Parameter extends Node +{ /** * Parameter name. * @@ -29,7 +29,7 @@ class Parameter extends Node { /** * vCard 2.1 allows parameters to be encoded without a name. * - * We can deduce the parameter name based on it's value. + * We can deduce the parameter name based on its value. * * @var bool */ @@ -50,8 +50,8 @@ class Parameter extends Node { * @param string $name * @param string $value */ - function __construct(Document $root, $name, $value = null) { - + public function __construct(Document $root, $name, $value = null) + { $this->name = strtoupper($name); $this->root = $root; if (is_null($name)) { @@ -62,13 +62,12 @@ class Parameter extends Node { // If guessParameterNameByValue() returns an empty string // above, we're actually dealing with a parameter that has no value. // In that case we have to move the value to the name. - if ($this->name === '') { + if ('' === $this->name) { $this->noName = false; $this->name = strtoupper($value); } else { $this->setValue($value); } - } /** @@ -82,85 +81,85 @@ class Parameter extends Node { * * @return string */ - static function guessParameterNameByValue($value) { + public static function guessParameterNameByValue($value) + { switch (strtoupper($value)) { - // Encodings - case '7-BIT' : - case 'QUOTED-PRINTABLE' : - case 'BASE64' : + case '7-BIT': + case 'QUOTED-PRINTABLE': + case 'BASE64': $name = 'ENCODING'; break; // Common types - case 'WORK' : - case 'HOME' : - case 'PREF' : + case 'WORK': + case 'HOME': + case 'PREF': // Delivery Label Type - case 'DOM' : - case 'INTL' : - case 'POSTAL' : - case 'PARCEL' : + case 'DOM': + case 'INTL': + case 'POSTAL': + case 'PARCEL': // Telephone types - case 'VOICE' : - case 'FAX' : - case 'MSG' : - case 'CELL' : - case 'PAGER' : - case 'BBS' : - case 'MODEM' : - case 'CAR' : - case 'ISDN' : - case 'VIDEO' : + case 'VOICE': + case 'FAX': + case 'MSG': + case 'CELL': + case 'PAGER': + case 'BBS': + case 'MODEM': + case 'CAR': + case 'ISDN': + case 'VIDEO': // EMAIL types (lol) - case 'AOL' : - case 'APPLELINK' : - case 'ATTMAIL' : - case 'CIS' : - case 'EWORLD' : - case 'INTERNET' : - case 'IBMMAIL' : - case 'MCIMAIL' : - case 'POWERSHARE' : - case 'PRODIGY' : - case 'TLX' : - case 'X400' : + case 'AOL': + case 'APPLELINK': + case 'ATTMAIL': + case 'CIS': + case 'EWORLD': + case 'INTERNET': + case 'IBMMAIL': + case 'MCIMAIL': + case 'POWERSHARE': + case 'PRODIGY': + case 'TLX': + case 'X400': // Photo / Logo format types - case 'GIF' : - case 'CGM' : - case 'WMF' : - case 'BMP' : - case 'DIB' : - case 'PICT' : - case 'TIFF' : - case 'PDF' : - case 'PS' : - case 'JPEG' : - case 'MPEG' : - case 'MPEG2' : - case 'AVI' : - case 'QTIME' : + case 'GIF': + case 'CGM': + case 'WMF': + case 'BMP': + case 'DIB': + case 'PICT': + case 'TIFF': + case 'PDF': + case 'PS': + case 'JPEG': + case 'MPEG': + case 'MPEG2': + case 'AVI': + case 'QTIME': // Sound Digital Audio Type - case 'WAVE' : - case 'PCM' : - case 'AIFF' : + case 'WAVE': + case 'PCM': + case 'AIFF': // Key types - case 'X509' : - case 'PGP' : + case 'X509': + case 'PGP': $name = 'TYPE'; break; // Value types - case 'INLINE' : - case 'URL' : - case 'CONTENT-ID' : - case 'CID' : + case 'INLINE': + case 'URL': + case 'CONTENT-ID': + case 'CID': $name = 'VALUE'; break; @@ -177,13 +176,10 @@ class Parameter extends Node { * This may be either a single, or multiple strings in an array. * * @param string|array $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { $this->value = $value; - } /** @@ -194,27 +190,23 @@ class Parameter extends Node { * * @return string|null */ - function getValue() { - + public function getValue() + { if (is_array($this->value)) { return implode(',', $this->value); } else { return $this->value; } - } /** * Sets multiple values for this parameter. * * @param array $value - * - * @return void */ - function setParts(array $value) { - + public function setParts(array $value) + { $this->value = $value; - } /** @@ -224,8 +216,8 @@ class Parameter extends Node { * * @return array */ - function getParts() { - + public function getParts() + { if (is_array($this->value)) { return $this->value; } elseif (is_null($this->value)) { @@ -233,7 +225,6 @@ class Parameter extends Node { } else { return [$this->value]; } - } /** @@ -243,17 +234,14 @@ class Parameter extends Node { * parameter value list. * * @param string|array $part - * - * @return void */ - function addValue($part) { - + public function addValue($part) + { if (is_null($this->value)) { $this->value = $part; } else { - $this->value = array_merge((array)$this->value, (array)$part); + $this->value = array_merge((array) $this->value, (array) $part); } - } /** @@ -267,13 +255,12 @@ class Parameter extends Node { * * @return bool */ - function has($value) { - + public function has($value) + { return in_array( strtolower($value), - array_map('strtolower', (array)$this->value) + array_map('strtolower', (array) $this->value) ); - } /** @@ -281,25 +268,24 @@ class Parameter extends Node { * * @return string */ - function serialize() { - + public function serialize() + { $value = $this->getParts(); - if (count($value) === 0) { - return $this->name . '='; + if (0 === count($value)) { + return $this->name.'='; } - if ($this->root->getDocumentType() === Document::VCARD21 && $this->noName) { - + if (Document::VCARD21 === $this->root->getDocumentType() && $this->noName) { return implode(';', $value); - } - return $this->name . '=' . array_reduce( + return $this->name.'='.array_reduce( $value, - function($out, $item) { - - if (!is_null($out)) $out .= ','; + function ($out, $item) { + if (!is_null($out)) { + $out .= ','; + } // If there's no special characters in the string, we'll use the simple // format. @@ -318,24 +304,23 @@ class Parameter extends Node { // severaly trips on + characters not being quoted, so we // added + as well. if (!preg_match('#(?: [\n":;\^,\+] )#x', $item)) { - return $out . $item; + return $out.$item; } else { // Enclosing in double-quotes, and using RFC6868 for encoding any // special characters - $out .= '"' . strtr( + $out .= '"'.strtr( $item, [ - '^' => '^^', + '^' => '^^', "\n" => '^n', - '"' => '^\'', + '"' => '^\'', ] - ) . '"'; + ).'"'; + return $out; } - } ); - } /** @@ -344,26 +329,22 @@ class Parameter extends Node { * * @return array */ - function jsonSerialize() { - + public function jsonSerialize() + { return $this->value; - } /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - function xmlSerialize(Xml\Writer $writer) { - + public function xmlSerialize(Xml\Writer $writer) + { foreach (explode(',', $this->value) as $value) { $writer->writeElement('text', $value); } - } /** @@ -371,10 +352,9 @@ class Parameter extends Node { * * @return string */ - function __toString() { - - return (string)$this->getValue(); - + public function __toString() + { + return (string) $this->getValue(); } /** @@ -382,13 +362,12 @@ class Parameter extends Node { * * @return ElementList */ - function getIterator() { - - if (!is_null($this->iterator)) + public function getIterator() + { + if (!is_null($this->iterator)) { return $this->iterator; + } - return $this->iterator = new ArrayIterator((array)$this->value); - + return $this->iterator = new ArrayIterator((array) $this->value); } - } diff --git a/vendor/sabre/vobject/lib/ParseException.php b/vendor/sabre/vobject/lib/ParseException.php index d96d20720..a8f497b24 100644 --- a/vendor/sabre/vobject/lib/ParseException.php +++ b/vendor/sabre/vobject/lib/ParseException.php @@ -9,5 +9,6 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ParseException extends \Exception { +class ParseException extends \Exception +{ } diff --git a/vendor/sabre/vobject/lib/Parser/Json.php b/vendor/sabre/vobject/lib/Parser/Json.php index a77258a2e..3fd307e97 100644 --- a/vendor/sabre/vobject/lib/Parser/Json.php +++ b/vendor/sabre/vobject/lib/Parser/Json.php @@ -4,6 +4,7 @@ namespace Sabre\VObject\Parser; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VCard; +use Sabre\VObject\Document; use Sabre\VObject\EofException; use Sabre\VObject\ParseException; @@ -16,8 +17,8 @@ use Sabre\VObject\ParseException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Json extends Parser { - +class Json extends Parser +{ /** * The input data. * @@ -41,12 +42,12 @@ class Json extends Parser { * If either input or options are not supplied, the defaults will be used. * * @param resource|string|array|null $input - * @param int $options + * @param int $options * - * @return Sabre\VObject\Document + * @return \Sabre\VObject\Document */ - function parse($input = null, $options = 0) { - + public function parse($input = null, $options = 0) + { if (!is_null($input)) { $this->setInput($input); } @@ -59,28 +60,28 @@ class Json extends Parser { } switch ($this->input[0]) { - case 'vcalendar' : + case 'vcalendar': $this->root = new VCalendar([], false); break; - case 'vcard' : + case 'vcard': $this->root = new VCard([], false); break; - default : + default: throw new ParseException('The root component must either be a vcalendar, or a vcard'); - } foreach ($this->input[1] as $prop) { $this->root->add($this->parseProperty($prop)); } - if (isset($this->input[2])) foreach ($this->input[2] as $comp) { - $this->root->add($this->parseComponent($comp)); + if (isset($this->input[2])) { + foreach ($this->input[2] as $comp) { + $this->root->add($this->parseComponent($comp)); + } } // Resetting the input so we can throw an feof exception the next time. $this->input = null; return $this->root; - } /** @@ -90,35 +91,34 @@ class Json extends Parser { * * @return \Sabre\VObject\Component */ - function parseComponent(array $jComp) { - + public function parseComponent(array $jComp) + { // We can remove $self from PHP 5.4 onward. $self = $this; $properties = array_map( - function($jProp) use ($self) { + function ($jProp) use ($self) { return $self->parseProperty($jProp); }, $jComp[1] ); if (isset($jComp[2])) { - $components = array_map( - function($jComp) use ($self) { + function ($jComp) use ($self) { return $self->parseComponent($jComp); }, $jComp[2] ); - - } else $components = []; + } else { + $components = []; + } return $this->root->createComponent( $jComp[0], array_merge($properties, $components), $defaults = false ); - } /** @@ -128,8 +128,8 @@ class Json extends Parser { * * @return \Sabre\VObject\Property */ - function parseProperty(array $jProp) { - + public function parseProperty(array $jProp) + { list( $propertyName, $parameters, @@ -142,14 +142,14 @@ class Json extends Parser { // value type. We're using this value later in this function. $defaultPropertyClass = $this->root->getClassNameForPropertyName($propertyName); - $parameters = (array)$parameters; + $parameters = (array) $parameters; $value = array_slice($jProp, 3); $valueType = strtoupper($valueType); if (isset($parameters['group'])) { - $propertyName = $parameters['group'] . '.' . $propertyName; + $propertyName = $parameters['group'].'.'.$propertyName; unset($parameters['group']); } @@ -160,7 +160,7 @@ class Json extends Parser { // represents TEXT values. We have to normalize these here. In the // future we can get rid of FlatText once we're allowed to break BC // again. - if ($defaultPropertyClass === 'Sabre\VObject\Property\FlatText') { + if ('Sabre\VObject\Property\FlatText' === $defaultPropertyClass) { $defaultPropertyClass = 'Sabre\VObject\Property\Text'; } @@ -168,22 +168,19 @@ class Json extends Parser { // type for the given property (e.g.: BDAY), we need to add a VALUE= // parameter. if ($defaultPropertyClass !== get_class($prop)) { - $prop["VALUE"] = $valueType; + $prop['VALUE'] = $valueType; } return $prop; - } /** * Sets the input data. * * @param resource|string|array $input - * - * @return void */ - function setInput($input) { - + public function setInput($input) + { if (is_resource($input)) { $input = stream_get_contents($input); } @@ -191,7 +188,5 @@ class Json extends Parser { $input = json_decode($input); } $this->input = $input; - } - } diff --git a/vendor/sabre/vobject/lib/Parser/MimeDir.php b/vendor/sabre/vobject/lib/Parser/MimeDir.php index 742641236..10dcec89c 100644 --- a/vendor/sabre/vobject/lib/Parser/MimeDir.php +++ b/vendor/sabre/vobject/lib/Parser/MimeDir.php @@ -7,6 +7,7 @@ use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VCard; use Sabre\VObject\Document; use Sabre\VObject\EofException; +use Sabre\VObject\Node; use Sabre\VObject\ParseException; /** @@ -22,8 +23,8 @@ use Sabre\VObject\ParseException; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class MimeDir extends Parser { - +class MimeDir extends Parser +{ /** * The input stream. * @@ -70,12 +71,12 @@ class MimeDir extends Parser { * used. * * @param string|resource|null $input - * @param int $options + * @param int $options * - * @return Sabre\VObject\Document + * @return \Sabre\VObject\Document */ - function parse($input = null, $options = 0) { - + public function parse($input = null, $options = 0) + { $this->root = null; if (!is_null($input)) { @@ -89,7 +90,6 @@ class MimeDir extends Parser { $this->parseDocument(); return $this->root; - } /** @@ -104,24 +104,21 @@ class MimeDir extends Parser { * * @param string $charset */ - function setCharset($charset) { - + public function setCharset($charset) + { if (!in_array($charset, self::$SUPPORTED_CHARSETS)) { - throw new \InvalidArgumentException('Unsupported encoding. (Supported encodings: ' . implode(', ', self::$SUPPORTED_CHARSETS) . ')'); + throw new \InvalidArgumentException('Unsupported encoding. (Supported encodings: '.implode(', ', self::$SUPPORTED_CHARSETS).')'); } $this->charset = $charset; - } /** * Sets the input buffer. Must be a string or stream. * * @param resource|string $input - * - * @return void */ - function setInput($input) { - + public function setInput($input) + { // Resetting the parser $this->lineIndex = 0; $this->startLine = 0; @@ -137,59 +134,53 @@ class MimeDir extends Parser { } else { throw new \InvalidArgumentException('This parser can only read from strings or streams.'); } - } /** * Parses an entire document. - * - * @return void */ - protected function parseDocument() { - + protected function parseDocument() + { $line = $this->readLine(); // BOM is ZERO WIDTH NO-BREAK SPACE (U+FEFF). // It's 0xEF 0xBB 0xBF in UTF-8 hex. if (3 <= strlen($line) - && ord($line[0]) === 0xef - && ord($line[1]) === 0xbb - && ord($line[2]) === 0xbf) { + && 0xef === ord($line[0]) + && 0xbb === ord($line[1]) + && 0xbf === ord($line[2])) { $line = substr($line, 3); } switch (strtoupper($line)) { - case 'BEGIN:VCALENDAR' : + case 'BEGIN:VCALENDAR': $class = VCalendar::$componentMap['VCALENDAR']; break; - case 'BEGIN:VCARD' : + case 'BEGIN:VCARD': $class = VCard::$componentMap['VCARD']; break; - default : + default: throw new ParseException('This parser only supports VCARD and VCALENDAR files'); } $this->root = new $class([], false); while (true) { - // Reading until we hit END: $line = $this->readLine(); - if (strtoupper(substr($line, 0, 4)) === 'END:') { + if ('END:' === strtoupper(substr($line, 0, 4))) { break; } $result = $this->parseLine($line); if ($result) { $this->root->add($result); } - } $name = strtoupper(substr($line, 4)); if ($name !== $this->root->name) { - throw new ParseException('Invalid MimeDir file. expected: "END:' . $this->root->name . '" got: "END:' . $name . '"'); + throw new ParseException('Invalid MimeDir file. expected: "END:'.$this->root->name.'" got: "END:'.$name.'"'); } - } /** @@ -200,46 +191,40 @@ class MimeDir extends Parser { * * @return Node */ - protected function parseLine($line) { - + protected function parseLine($line) + { // Start of a new component - if (strtoupper(substr($line, 0, 6)) === 'BEGIN:') { - + if ('BEGIN:' === strtoupper(substr($line, 0, 6))) { $component = $this->root->createComponent(substr($line, 6), [], false); while (true) { - // Reading until we hit END: $line = $this->readLine(); - if (strtoupper(substr($line, 0, 4)) === 'END:') { + if ('END:' === strtoupper(substr($line, 0, 4))) { break; } $result = $this->parseLine($line); if ($result) { $component->add($result); } - } $name = strtoupper(substr($line, 4)); if ($name !== $component->name) { - throw new ParseException('Invalid MimeDir file. expected: "END:' . $component->name . '" got: "END:' . $name . '"'); + throw new ParseException('Invalid MimeDir file. expected: "END:'.$component->name.'" got: "END:'.$name.'"'); } return $component; - } else { - // Property reader $property = $this->readProperty($line); if (!$property) { // Ignored line return false; } - return $property; + return $property; } - } /** @@ -248,7 +233,7 @@ class MimeDir extends Parser { * * If that was not the case, we store it here. * - * @var null|string + * @var string|null */ protected $lineBuffer; @@ -281,8 +266,8 @@ class MimeDir extends Parser { * * @return string */ - protected function readLine() { - + protected function readLine() + { if (!\is_null($this->lineBuffer)) { $rawLine = $this->lineBuffer; $this->lineBuffer = null; @@ -292,15 +277,15 @@ class MimeDir extends Parser { $rawLine = \fgets($this->input); - if ($eof || (\feof($this->input) && $rawLine === false)) { + if ($eof || (\feof($this->input) && false === $rawLine)) { throw new EofException('End of document reached prematurely'); } - if ($rawLine === false) { + if (false === $rawLine) { throw new ParseException('Error reading from input stream'); } $rawLine = \rtrim($rawLine, "\r\n"); - } while ($rawLine === ''); // Skipping empty lines - $this->lineIndex++; + } while ('' === $rawLine); // Skipping empty lines + ++$this->lineIndex; } $line = $rawLine; @@ -308,34 +293,30 @@ class MimeDir extends Parser { // Looking ahead for folded lines. while (true) { - $nextLine = \rtrim(\fgets($this->input), "\r\n"); - $this->lineIndex++; + ++$this->lineIndex; if (!$nextLine) { break; } - if ($nextLine[0] === "\t" || $nextLine[0] === " ") { + if ("\t" === $nextLine[0] || ' ' === $nextLine[0]) { $curLine = \substr($nextLine, 1); $line .= $curLine; - $rawLine .= "\n " . $curLine; + $rawLine .= "\n ".$curLine; } else { $this->lineBuffer = $nextLine; break; } - } $this->rawLine = $rawLine; - return $line; + return $line; } /** * Reads a property or component from a line. - * - * @return void */ - protected function readProperty($line) { - + protected function readProperty($line) + { if ($this->options & self::OPTION_FORGIVING) { $propNameToken = 'A-Z0-9\-\._\\/'; } else { @@ -360,17 +341,17 @@ class MimeDir extends Parser { /xi"; //echo $regex, "\n"; die(); - preg_match_all($regex, $line, $matches, PREG_SET_ORDER); + preg_match_all($regex, $line, $matches, PREG_SET_ORDER); $property = [ - 'name' => null, + 'name' => null, 'parameters' => [], - 'value' => null + 'value' => null, ]; $lastParam = null; - /** + /* * Looping through all the tokens. * * Note that we are looping through them in reverse order, because if a @@ -378,9 +359,8 @@ class MimeDir extends Parser { * in the result. */ foreach ($matches as $match) { - if (isset($match['paramValue'])) { - if ($match['paramValue'] && $match['paramValue'][0] === '"') { + if ($match['paramValue'] && '"' === $match['paramValue'][0]) { $value = substr($match['paramValue'], 1, -1); } else { $value = $match['paramValue']; @@ -389,7 +369,7 @@ class MimeDir extends Parser { $value = $this->unescapeParam($value); if (is_null($lastParam)) { - throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions'); + throw new ParseException('Invalid Mimedir file. Line starting at '.$this->startLine.' did not follow iCalendar/vCard conventions'); } if (is_null($property['parameters'][$lastParam])) { $property['parameters'][$lastParam] = $value; @@ -398,7 +378,7 @@ class MimeDir extends Parser { } else { $property['parameters'][$lastParam] = [ $property['parameters'][$lastParam], - $value + $value, ]; } continue; @@ -422,7 +402,6 @@ class MimeDir extends Parser { // @codeCoverageIgnoreStart throw new \LogicException('This code should not be reachable'); // @codeCoverageIgnoreEnd - } if (is_null($property['value'])) { @@ -432,11 +411,11 @@ class MimeDir extends Parser { if ($this->options & self::OPTION_IGNORE_INVALID_LINES) { return false; } - throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions'); + throw new ParseException('Invalid Mimedir file. Line starting at '.$this->startLine.' did not follow iCalendar/vCard conventions'); } // vCard 2.1 states that parameters may appear without a name, and only - // a value. We can deduce the value based on it's name. + // a value. We can deduce the value based on its name. // // Our parser will get those as parameters without a value instead, so // we're filtering these parameters out first. @@ -457,31 +436,30 @@ class MimeDir extends Parser { $propObj->add(null, $namelessParameter); } - if (strtoupper($propObj['ENCODING']) === 'QUOTED-PRINTABLE') { + if ('QUOTED-PRINTABLE' === strtoupper($propObj['ENCODING'])) { $propObj->setQuotedPrintableValue($this->extractQuotedPrintableValue()); } else { $charset = $this->charset; - if ($this->root->getDocumentType() === Document::VCARD21 && isset($propObj['CHARSET'])) { + if (Document::VCARD21 === $this->root->getDocumentType() && isset($propObj['CHARSET'])) { // vCard 2.1 allows the character set to be specified per property. - $charset = (string)$propObj['CHARSET']; + $charset = (string) $propObj['CHARSET']; } switch (strtolower($charset)) { - case 'utf-8' : + case 'utf-8': break; - case 'iso-8859-1' : + case 'iso-8859-1': $property['value'] = utf8_encode($property['value']); break; - case 'windows-1252' : + case 'windows-1252': $property['value'] = mb_convert_encoding($property['value'], 'UTF-8', $charset); break; - default : - throw new ParseException('Unsupported CHARSET: ' . $propObj['CHARSET']); + default: + throw new ParseException('Unsupported CHARSET: '.$propObj['CHARSET']); } $propObj->setRawMimeDirValue($property['value']); } return $propObj; - } /** @@ -546,11 +524,11 @@ class MimeDir extends Parser { * * @return string|string[] */ - static function unescapeValue($input, $delimiter = ';') { - + public static function unescapeValue($input, $delimiter = ';') + { $regex = '# (?: (\\\\ (?: \\\\ | N | n | ; | , ) )'; if ($delimiter) { - $regex .= ' | (' . $delimiter . ')'; + $regex .= ' | ('.$delimiter.')'; } $regex .= ') #x'; @@ -560,36 +538,33 @@ class MimeDir extends Parser { $result = ''; foreach ($matches as $match) { - switch ($match) { - case '\\\\' : + case '\\\\': $result .= '\\'; break; - case '\N' : - case '\n' : + case '\N': + case '\n': $result .= "\n"; break; - case '\;' : + case '\;': $result .= ';'; break; - case '\,' : + case '\,': $result .= ','; break; - case $delimiter : + case $delimiter: $resultArray[] = $result; $result = ''; break; - default : + default: $result .= $match; break; - } - } $resultArray[] = $result; - return $delimiter ? $resultArray : $result; + return $delimiter ? $resultArray : $result; } /** @@ -623,21 +598,19 @@ class MimeDir extends Parser { * * " is encoded as ^' * * @param string $input - * - * @return void */ - private function unescapeParam($input) { - + private function unescapeParam($input) + { return preg_replace_callback( '#(\^(\^|n|\'))#', - function($matches) { + function ($matches) { switch ($matches[2]) { - case 'n' : + case 'n': return "\n"; - case '^' : + case '^': return '^'; - case '\'' : + case '\'': return '"'; // @codeCoverageIgnoreStart @@ -658,8 +631,8 @@ class MimeDir extends Parser { * * @return string */ - private function extractQuotedPrintableValue() { - + private function extractQuotedPrintableValue() + { // We need to parse the raw line again to get the start of the value. // // We are basically looking for the first colon (:), but we need to @@ -682,16 +655,14 @@ class MimeDir extends Parser { // missing a whitespace. So if 'forgiving' is turned on, we will take // those as well. if ($this->options & self::OPTION_FORGIVING) { - while (substr($value, -1) === '=') { + while ('=' === substr($value, -1)) { // Reading the line $this->readLine(); // Grabbing the raw form - $value .= "\n" . $this->rawLine; + $value .= "\n".$this->rawLine; } } return $value; - } - } diff --git a/vendor/sabre/vobject/lib/Parser/Parser.php b/vendor/sabre/vobject/lib/Parser/Parser.php index ca8bc0add..b7b611430 100644 --- a/vendor/sabre/vobject/lib/Parser/Parser.php +++ b/vendor/sabre/vobject/lib/Parser/Parser.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Parser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Parser { - +abstract class Parser +{ /** * Turning on this option makes the parser more forgiving. * @@ -41,12 +41,10 @@ abstract class Parser { * Optionally, it's possible to parse the input stream here. * * @param mixed $input - * @param int $options Any parser options (OPTION constants). - * - * @return void + * @param int $options any parser options (OPTION constants) */ - function __construct($input = null, $options = 0) { - + public function __construct($input = null, $options = 0) + { if (!is_null($input)) { $this->setInput($input); } @@ -62,19 +60,16 @@ abstract class Parser { * If either input or options are not supplied, the defaults will be used. * * @param mixed $input - * @param int $options + * @param int $options * * @return array */ - abstract function parse($input = null, $options = 0); + abstract public function parse($input = null, $options = 0); /** * Sets the input data. * * @param mixed $input - * - * @return void */ - abstract function setInput($input); - + abstract public function setInput($input); } diff --git a/vendor/sabre/vobject/lib/Parser/XML.php b/vendor/sabre/vobject/lib/Parser/XML.php index 5ac423984..90f262d9e 100644 --- a/vendor/sabre/vobject/lib/Parser/XML.php +++ b/vendor/sabre/vobject/lib/Parser/XML.php @@ -18,8 +18,8 @@ use Sabre\Xml as SabreXml; * @author Ivan Enderlin * @license http://sabre.io/license/ Modified BSD License */ -class XML extends Parser { - +class XML extends Parser +{ const XCAL_NAMESPACE = 'urn:ietf:params:xml:ns:icalendar-2.0'; const XCARD_NAMESPACE = 'urn:ietf:params:xml:ns:vcard-4.0'; @@ -40,7 +40,7 @@ class XML extends Parser { /** * Document, root component. * - * @var Sabre\VObject\Document + * @var \Sabre\VObject\Document */ protected $root; @@ -50,32 +50,29 @@ class XML extends Parser { * Optionally, it's possible to parse the input stream here. * * @param mixed $input - * @param int $options Any parser options (OPTION constants). - * - * @return void + * @param int $options any parser options (OPTION constants) */ - function __construct($input = null, $options = 0) { - + public function __construct($input = null, $options = 0) + { if (0 === $options) { $options = parent::OPTION_FORGIVING; } parent::__construct($input, $options); - } /** * Parse xCal or xCard. * * @param resource|string $input - * @param int $options + * @param int $options * * @throws \Exception * - * @return Sabre\VObject\Document + * @return \Sabre\VObject\Document */ - function parse($input = null, $options = 0) { - + public function parse($input = null, $options = 0) + { if (!is_null($input)) { $this->setInput($input); } @@ -89,29 +86,25 @@ class XML extends Parser { } switch ($this->input['name']) { - - case '{' . self::XCAL_NAMESPACE . '}icalendar': + case '{'.self::XCAL_NAMESPACE.'}icalendar': $this->root = new VCalendar([], false); $this->pointer = &$this->input['value'][0]; $this->parseVCalendarComponents($this->root); break; - case '{' . self::XCARD_NAMESPACE . '}vcards': + case '{'.self::XCARD_NAMESPACE.'}vcards': foreach ($this->input['value'] as &$vCard) { - $this->root = new VCard(['version' => '4.0'], false); $this->pointer = &$vCard; $this->parseVCardComponents($this->root); // We just parse the first <vcard /> element. break; - } break; default: throw new ParseException('Unsupported XML standard'); - } return $this->root; @@ -121,15 +114,11 @@ class XML extends Parser { * Parse a xCalendar component. * * @param Component $parentComponent - * - * @return void */ - protected function parseVCalendarComponents(Component $parentComponent) { - + protected function parseVCalendarComponents(Component $parentComponent) + { foreach ($this->pointer['value'] ?: [] as $children) { - switch (static::getTagName($children['name'])) { - case 'properties': $this->pointer = &$children['value']; $this->parseProperties($parentComponent); @@ -141,35 +130,28 @@ class XML extends Parser { break; } } - } /** * Parse a xCard component. * * @param Component $parentComponent - * - * @return void */ - protected function parseVCardComponents(Component $parentComponent) { - + protected function parseVCardComponents(Component $parentComponent) + { $this->pointer = &$this->pointer['value']; $this->parseProperties($parentComponent); - } /** * Parse xCalendar and xCard properties. * * @param Component $parentComponent - * @param string $propertyNamePrefix - * - * @return void + * @param string $propertyNamePrefix */ - protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '') { - + protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '') + { foreach ($this->pointer ?: [] as $xmlProperty) { - list($namespace, $tagName) = SabreXml\Service::parseClarkNotation($xmlProperty['name']); $propertyName = $tagName; @@ -178,17 +160,16 @@ class XML extends Parser { $propertyType = 'text'; // A property which is not part of the standard. - if ($namespace !== self::XCAL_NAMESPACE - && $namespace !== self::XCARD_NAMESPACE) { - + if (self::XCAL_NAMESPACE !== $namespace + && self::XCARD_NAMESPACE !== $namespace) { $propertyName = 'xml'; - $value = '<' . $tagName . ' xmlns="' . $namespace . '"'; + $value = '<'.$tagName.' xmlns="'.$namespace.'"'; foreach ($xmlProperty['attributes'] as $attributeName => $attributeValue) { - $value .= ' ' . $attributeName . '="' . str_replace('"', '\"', $attributeValue) . '"'; + $value .= ' '.$attributeName.'="'.str_replace('"', '\"', $attributeValue).'"'; } - $value .= '>' . $xmlProperty['value'] . '</' . $tagName . '>'; + $value .= '>'.$xmlProperty['value'].'</'.$tagName.'>'; $propertyValue = [$value]; @@ -204,8 +185,7 @@ class XML extends Parser { } // xCard group. - if ($propertyName === 'group') { - + if ('group' === $propertyName) { if (!isset($xmlProperty['attributes']['name'])) { continue; } @@ -213,24 +193,22 @@ class XML extends Parser { $this->pointer = &$xmlProperty['value']; $this->parseProperties( $parentComponent, - strtoupper($xmlProperty['attributes']['name']) . '.' + strtoupper($xmlProperty['attributes']['name']).'.' ); continue; - } // Collect parameters. foreach ($xmlProperty['value'] as $i => $xmlPropertyChild) { - if (!is_array($xmlPropertyChild) - || 'parameters' !== static::getTagName($xmlPropertyChild['name'])) + || 'parameters' !== static::getTagName($xmlPropertyChild['name'])) { continue; + } $xmlParameters = $xmlPropertyChild['value']; foreach ($xmlParameters as $xmlParameter) { - $propertyParameterValues = []; foreach ($xmlParameter['value'] as $xmlParameterValues) { @@ -239,19 +217,16 @@ class XML extends Parser { $propertyParameters[static::getTagName($xmlParameter['name'])] = implode(',', $propertyParameterValues); - } array_splice($xmlProperty['value'], $i, 1); - } $propertyNameExtended = ($this->root instanceof VCalendar ? 'xcal' - : 'xcard') . ':' . $propertyName; + : 'xcard').':'.$propertyName; switch ($propertyNameExtended) { - case 'xcal:geo': $propertyType = 'float'; $propertyValue['latitude'] = 0; @@ -277,6 +252,7 @@ class XML extends Parser { // We don't break because we only want to set // another property type. + // no break case 'xcal:categories': case 'xcal:resources': case 'xcal:exdate': @@ -290,16 +266,12 @@ class XML extends Parser { $propertyType = 'date-time'; foreach ($xmlProperty['value'] as $specialChild) { - $tagName = static::getTagName($specialChild['name']); if ('period' === $tagName) { - $propertyParameters['value'] = 'PERIOD'; $propertyValue[] = implode('/', $specialChild['value']); - - } - else { + } else { $propertyValue[] = $specialChild['value']; } } @@ -320,29 +292,24 @@ class XML extends Parser { $this->createProperty( $parentComponent, - $propertyNamePrefix . $propertyName, + $propertyNamePrefix.$propertyName, $propertyParameters, $propertyType, $propertyValue ); - } - } /** * Parse a component. * * @param Component $parentComponent - * - * @return void */ - protected function parseComponent(Component $parentComponent) { - + protected function parseComponent(Component $parentComponent) + { $components = $this->pointer['value'] ?: []; foreach ($components as $component) { - $componentName = static::getTagName($component['name']); $currentComponent = $this->root->createComponent( $componentName, @@ -354,24 +321,20 @@ class XML extends Parser { $this->parseVCalendarComponents($currentComponent); $parentComponent->add($currentComponent); - } - } /** * Create a property. * * @param Component $parentComponent - * @param string $name - * @param array $parameters - * @param string $type - * @param mixed $value - * - * @return void + * @param string $name + * @param array $parameters + * @param string $type + * @param mixed $value */ - protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value) { - + protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value) + { $property = $this->root->createProperty( $name, null, @@ -380,36 +343,30 @@ class XML extends Parser { ); $parentComponent->add($property); $property->setXmlValue($value); - } /** * Sets the input data. * * @param resource|string $input - * - * @return void */ - function setInput($input) { - + public function setInput($input) + { if (is_resource($input)) { $input = stream_get_contents($input); } if (is_string($input)) { - $reader = new SabreXml\Reader(); - $reader->elementMap['{' . self::XCAL_NAMESPACE . '}period'] + $reader->elementMap['{'.self::XCAL_NAMESPACE.'}period'] = 'Sabre\VObject\Parser\XML\Element\KeyValue'; - $reader->elementMap['{' . self::XCAL_NAMESPACE . '}recur'] + $reader->elementMap['{'.self::XCAL_NAMESPACE.'}recur'] = 'Sabre\VObject\Parser\XML\Element\KeyValue'; $reader->xml($input); $input = $reader->parse(); - } $this->input = $input; - } /** @@ -419,10 +376,10 @@ class XML extends Parser { * * @return string */ - protected static function getTagName($clarkedTagName) { - + protected static function getTagName($clarkedTagName) + { list(, $tagName) = SabreXml\Service::parseClarkNotation($clarkedTagName); - return $tagName; + return $tagName; } } diff --git a/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php b/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php index 14d798433..e26540036 100644 --- a/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php +++ b/vendor/sabre/vobject/lib/Parser/XML/Element/KeyValue.php @@ -13,8 +13,8 @@ use Sabre\Xml as SabreXml; * @author Ivan Enderlin * @license http://sabre.io/license/ Modified BSD License */ -class KeyValue extends SabreXml\Element\KeyValue { - +class KeyValue extends SabreXml\Element\KeyValue +{ /** * The deserialize method is called during xml parsing. * @@ -37,11 +37,12 @@ class KeyValue extends SabreXml\Element\KeyValue { * * @return mixed */ - static function xmlDeserialize(SabreXml\Reader $reader) { - + public static function xmlDeserialize(SabreXml\Reader $reader) + { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { $reader->next(); + return []; } @@ -49,22 +50,16 @@ class KeyValue extends SabreXml\Element\KeyValue { $reader->read(); do { - - if ($reader->nodeType === SabreXml\Reader::ELEMENT) { - + if (SabreXml\Reader::ELEMENT === $reader->nodeType) { $name = $reader->localName; $values[$name] = $reader->parseCurrentElement()['value']; - } else { $reader->read(); } - - } while ($reader->nodeType !== SabreXml\Reader::END_ELEMENT); + } while (SabreXml\Reader::END_ELEMENT !== $reader->nodeType); $reader->read(); return $values; - } - } diff --git a/vendor/sabre/vobject/lib/Property.php b/vendor/sabre/vobject/lib/Property.php index 3d1775fa2..6105cb0f0 100644 --- a/vendor/sabre/vobject/lib/Property.php +++ b/vendor/sabre/vobject/lib/Property.php @@ -14,8 +14,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Property extends Node { - +abstract class Property extends Node +{ /** * Property name. * @@ -61,16 +61,14 @@ abstract class Property extends Node { * * Parameters must be specified in key=>value syntax. * - * @param Component $root The root document - * @param string $name + * @param Component $root The root document + * @param string $name * @param string|array|null $value - * @param array $parameters List of parameters - * @param string $group The vcard property group - * - * @return void + * @param array $parameters List of parameters + * @param string $group The vcard property group */ - function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) { - + public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) + { $this->name = $name; $this->group = $group; @@ -83,7 +81,6 @@ abstract class Property extends Node { if (!is_null($value)) { $this->setValue($value); } - } /** @@ -92,13 +89,10 @@ abstract class Property extends Node { * This may be either a single, or multiple strings in an array. * * @param string|array $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { $this->value = $value; - } /** @@ -112,12 +106,12 @@ abstract class Property extends Node { * * @return string */ - function getValue() { - + public function getValue() + { if (is_array($this->value)) { - if (count($this->value) == 0) { + if (0 == count($this->value)) { return; - } elseif (count($this->value) === 1) { + } elseif (1 === count($this->value)) { return $this->value[0]; } else { return $this->getRawMimeDirValue(); @@ -125,20 +119,16 @@ abstract class Property extends Node { } else { return $this->value; } - } /** * Sets a multi-valued property. * * @param array $parts - * - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { $this->value = $parts; - } /** @@ -149,8 +139,8 @@ abstract class Property extends Node { * * @return array */ - function getParts() { - + public function getParts() + { if (is_null($this->value)) { return []; } elseif (is_array($this->value)) { @@ -158,7 +148,6 @@ abstract class Property extends Node { } else { return [$this->value]; } - } /** @@ -166,22 +155,22 @@ abstract class Property extends Node { * * If a parameter with same name already existed, the values will be * combined. - * If nameless parameter is added, we try to guess it's name. + * If nameless parameter is added, we try to guess its name. * - * @param string $name - * @param string|null|array $value + * @param string $name + * @param string|array|null $value */ - function add($name, $value = null) { + public function add($name, $value = null) + { $noName = false; - if ($name === null) { + if (null === $name) { $name = Parameter::guessParameterNameByValue($value); $noName = true; } if (isset($this->parameters[strtoupper($name)])) { $this->parameters[strtoupper($name)]->addValue($value); - } - else { + } else { $param = new Parameter($this->root, $name, $value); $param->noName = $noName; $this->parameters[$param->name] = $param; @@ -193,10 +182,9 @@ abstract class Property extends Node { * * @return array */ - function parameters() { - + public function parameters() + { return $this->parameters; - } /** @@ -207,7 +195,7 @@ abstract class Property extends Node { * * @return string */ - abstract function getValueType(); + abstract public function getValueType(); /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. @@ -216,35 +204,33 @@ abstract class Property extends Node { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - abstract function setRawMimeDirValue($val); + abstract public function setRawMimeDirValue($val); /** * Returns a raw mime-dir representation of the value. * * @return string */ - abstract function getRawMimeDirValue(); + abstract public function getRawMimeDirValue(); /** * Turns the object back into a serialized blob. * * @return string */ - function serialize() { - + public function serialize() + { $str = $this->name; - if ($this->group) $str = $this->group . '.' . $this->name; + if ($this->group) { + $str = $this->group.'.'.$this->name; + } foreach ($this->parameters() as $param) { - - $str .= ';' . $param->serialize(); - + $str .= ';'.$param->serialize(); } - $str .= ':' . $this->getRawMimeDirValue(); + $str .= ':'.$this->getRawMimeDirValue(); $str = \preg_replace( '/( @@ -258,7 +244,6 @@ abstract class Property extends Node { // remove single space after last CRLF return \substr($str, 0, -1); - } /** @@ -268,10 +253,9 @@ abstract class Property extends Node { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return $this->getParts(); - } /** @@ -280,17 +264,14 @@ abstract class Property extends Node { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - - if (count($value) === 1) { + public function setJsonValue(array $value) + { + if (1 === count($value)) { $this->setValue(reset($value)); } else { $this->setValue($value); } - } /** @@ -299,12 +280,12 @@ abstract class Property extends Node { * * @return array */ - function jsonSerialize() { - + public function jsonSerialize() + { $parameters = []; foreach ($this->parameters as $parameter) { - if ($parameter->name === 'VALUE') { + if ('VALUE' === $parameter->name) { continue; } $parameters[strtolower($parameter->name)] = $parameter->jsonSerialize(); @@ -318,7 +299,7 @@ abstract class Property extends Node { return array_merge( [ strtolower($this->name), - (object)$parameters, + (object) $parameters, strtolower($this->getValueType()), ], $this->getJsonValue() @@ -330,78 +311,63 @@ abstract class Property extends Node { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $this->setJsonValue($value); - } /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - function xmlSerialize(Xml\Writer $writer) { - + public function xmlSerialize(Xml\Writer $writer) + { $parameters = []; foreach ($this->parameters as $parameter) { - - if ($parameter->name === 'VALUE') { + if ('VALUE' === $parameter->name) { continue; } $parameters[] = $parameter; - } $writer->startElement(strtolower($this->name)); if (!empty($parameters)) { - $writer->startElement('parameters'); foreach ($parameters as $parameter) { - $writer->startElement(strtolower($parameter->name)); $writer->write($parameter); $writer->endElement(); - } $writer->endElement(); - } $this->xmlSerializeValue($writer); $writer->endElement(); - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $valueType = strtolower($this->getValueType()); foreach ($this->getJsonValue() as $values) { - foreach ((array)$values as $value) { + foreach ((array) $values as $value) { $writer->writeElement($valueType, $value); } } - } /** @@ -413,10 +379,9 @@ abstract class Property extends Node { * * @return string */ - function __toString() { - - return (string)$this->getValue(); - + public function __toString() + { + return (string) $this->getValue(); } /* ArrayAccess interface {{{ */ @@ -428,17 +393,21 @@ abstract class Property extends Node { * * @return bool */ - function offsetExists($name) { - - if (is_int($name)) return parent::offsetExists($name); + public function offsetExists($name) + { + if (is_int($name)) { + return parent::offsetExists($name); + } $name = strtoupper($name); foreach ($this->parameters as $parameter) { - if ($parameter->name == $name) return true; + if ($parameter->name == $name) { + return true; + } } - return false; + return false; } /** @@ -450,9 +419,11 @@ abstract class Property extends Node { * * @return Node */ - function offsetGet($name) { - - if (is_int($name)) return parent::offsetGet($name); + public function offsetGet($name) + { + if (is_int($name)) { + return parent::offsetGet($name); + } $name = strtoupper($name); if (!isset($this->parameters[$name])) { @@ -460,19 +431,16 @@ abstract class Property extends Node { } return $this->parameters[$name]; - } /** * Creates a new parameter. * * @param string $name - * @param mixed $value - * - * @return void + * @param mixed $value */ - function offsetSet($name, $value) { - + public function offsetSet($name, $value) + { if (is_int($name)) { parent::offsetSet($name, $value); // @codeCoverageIgnoreStart @@ -484,18 +452,15 @@ abstract class Property extends Node { $param = new Parameter($this->root, $name, $value); $this->parameters[$param->name] = $param; - } /** * Removes one or more parameters with the specified name. * * @param string $name - * - * @return void */ - function offsetUnset($name) { - + public function offsetUnset($name) + { if (is_int($name)) { parent::offsetUnset($name); // @codeCoverageIgnoreStart @@ -506,23 +471,20 @@ abstract class Property extends Node { } unset($this->parameters[strtoupper($name)]); - } + /* }}} */ /** * This method is automatically called when the object is cloned. * Specifically, this will ensure all child elements are also cloned. - * - * @return void */ - function __clone() { - + public function __clone() + { foreach ($this->parameters as $key => $child) { $this->parameters[$key] = clone $child; $this->parameters[$key]->parent = $this; } - } /** @@ -543,13 +505,12 @@ abstract class Property extends Node { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $warnings = []; // Checking if our value is UTF-8 if (!StringUtil::isUTF8($this->getRawMimeDirValue())) { - $oldValue = $this->getRawMimeDirValue(); $level = 3; if ($options & self::REPAIR) { @@ -558,29 +519,27 @@ abstract class Property extends Node { $this->setRawMimeDirValue($newValue); $level = 1; } - } - if (preg_match('%([\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', $oldValue, $matches)) { - $message = 'Property contained a control character (0x' . bin2hex($matches[1]) . ')'; + $message = 'Property contained a control character (0x'.bin2hex($matches[1]).')'; } else { - $message = 'Property is not valid UTF-8! ' . $oldValue; + $message = 'Property is not valid UTF-8! '.$oldValue; } $warnings[] = [ - 'level' => $level, + 'level' => $level, 'message' => $message, - 'node' => $this, + 'node' => $this, ]; } // Checking if the propertyname does not contain any invalid bytes. if (!preg_match('/^([A-Z0-9-]+)$/', $this->name)) { $warnings[] = [ - 'level' => $options & self::REPAIR ? 1 : 3, - 'message' => 'The propertyname: ' . $this->name . ' contains invalid characters. Only A-Z, 0-9 and - are allowed', - 'node' => $this, + 'level' => $options & self::REPAIR ? 1 : 3, + 'message' => 'The propertyname: '.$this->name.' contains invalid characters. Only A-Z, 0-9 and - are allowed', + 'node' => $this, ]; if ($options & self::REPAIR) { // Uppercasing and converting underscores to dashes. @@ -589,46 +548,52 @@ abstract class Property extends Node { ); // Removing every other invalid character $this->name = preg_replace('/([^A-Z0-9-])/u', '', $this->name); - } - } if ($encoding = $this->offsetGet('ENCODING')) { - - if ($this->root->getDocumentType() === Document::VCARD40) { + if (Document::VCARD40 === $this->root->getDocumentType()) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'ENCODING parameter is not valid in vCard 4.', - 'node' => $this + 'node' => $this, ]; } else { - - $encoding = (string)$encoding; + $encoding = (string) $encoding; $allowedEncoding = []; switch ($this->root->getDocumentType()) { - case Document::ICALENDAR20 : + case Document::ICALENDAR20: $allowedEncoding = ['8BIT', 'BASE64']; break; - case Document::VCARD21 : + case Document::VCARD21: $allowedEncoding = ['QUOTED-PRINTABLE', 'BASE64', '8BIT']; break; - case Document::VCARD30 : + case Document::VCARD30: $allowedEncoding = ['B']; + //Repair vCard30 that use BASE64 encoding + if ($options & self::REPAIR) { + if ('BASE64' === strtoupper($encoding)) { + $encoding = 'B'; + $this['ENCODING'] = $encoding; + $warnings[] = [ + 'level' => 1, + 'message' => 'ENCODING=BASE64 has been transformed to ENCODING=B.', + 'node' => $this, + ]; + } + } break; - } if ($allowedEncoding && !in_array(strtoupper($encoding), $allowedEncoding)) { $warnings[] = [ - 'level' => 3, - 'message' => 'ENCODING=' . strtoupper($encoding) . ' is not valid for this document type.', - 'node' => $this + 'level' => 3, + 'message' => 'ENCODING='.strtoupper($encoding).' is not valid for this document type.', + 'node' => $this, ]; } } - } // Validating inner parameters @@ -637,7 +602,6 @@ abstract class Property extends Node { } return $warnings; - } /** @@ -645,17 +609,13 @@ abstract class Property extends Node { * * It's intended to remove all circular references, so PHP can easily clean * it up. - * - * @return void */ - function destroy() { - + public function destroy() + { parent::destroy(); foreach ($this->parameters as $param) { $param->destroy(); } $this->parameters = []; - } - } diff --git a/vendor/sabre/vobject/lib/Property/Binary.php b/vendor/sabre/vobject/lib/Property/Binary.php index d54cae25d..830dd9028 100644 --- a/vendor/sabre/vobject/lib/Property/Binary.php +++ b/vendor/sabre/vobject/lib/Property/Binary.php @@ -18,8 +18,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Binary extends Property { - +class Binary extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -34,25 +34,18 @@ class Binary extends Property { * This may be either a single, or multiple strings in an array. * * @param string|array $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { if (is_array($value)) { - - if (count($value) === 1) { + if (1 === count($value)) { $this->value = $value[0]; } else { throw new \InvalidArgumentException('The argument must either be a string or an array with only one child'); } - } else { - $this->value = $value; - } - } /** @@ -62,13 +55,10 @@ class Binary extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->value = base64_decode($val); - } /** @@ -76,10 +66,9 @@ class Binary extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return base64_encode($this->value); - } /** @@ -90,10 +79,9 @@ class Binary extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'BINARY'; - } /** @@ -103,10 +91,9 @@ class Binary extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return [base64_encode($this->getValue())]; - } /** @@ -115,14 +102,10 @@ class Binary extends Property { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { $value = array_map('base64_decode', $value); parent::setJsonValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/Boolean.php b/vendor/sabre/vobject/lib/Property/Boolean.php index 6f5887e25..1b219bb8c 100644 --- a/vendor/sabre/vobject/lib/Property/Boolean.php +++ b/vendor/sabre/vobject/lib/Property/Boolean.php @@ -17,8 +17,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Boolean extends Property { - +class Boolean extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -26,14 +26,11 @@ class Boolean extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - - $val = strtoupper($val) === 'TRUE' ? true : false; + public function setRawMimeDirValue($val) + { + $val = 'TRUE' === strtoupper($val) ? true : false; $this->setValue($val); - } /** @@ -41,10 +38,9 @@ class Boolean extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->value ? 'TRUE' : 'FALSE'; - } /** @@ -55,10 +51,9 @@ class Boolean extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'BOOLEAN'; - } /** @@ -66,19 +61,15 @@ class Boolean extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map( - function($value) { + function ($value) { return 'true' === $value; }, $value ); parent::setXmlValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/FlatText.php b/vendor/sabre/vobject/lib/Property/FlatText.php index 2c7b43c29..d15cfe051 100644 --- a/vendor/sabre/vobject/lib/Property/FlatText.php +++ b/vendor/sabre/vobject/lib/Property/FlatText.php @@ -22,8 +22,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FlatText extends Text { - +class FlatText extends Text +{ /** * Field separator. * @@ -37,14 +37,10 @@ class FlatText extends Text { * Overriding this so we're not splitting on a ; delimiter. * * @param string $val - * - * @return void */ - function setQuotedPrintableValue($val) { - + public function setQuotedPrintableValue($val) + { $val = quoted_printable_decode($val); $this->setValue($val); - } - } diff --git a/vendor/sabre/vobject/lib/Property/FloatValue.php b/vendor/sabre/vobject/lib/Property/FloatValue.php index 15b119549..208d74516 100644 --- a/vendor/sabre/vobject/lib/Property/FloatValue.php +++ b/vendor/sabre/vobject/lib/Property/FloatValue.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FloatValue extends Property { - +class FloatValue extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,17 +32,14 @@ class FloatValue extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $val = explode($this->delimiter, $val); foreach ($val as &$item) { - $item = (float)$item; + $item = (float) $item; } $this->setParts($val); - } /** @@ -50,13 +47,12 @@ class FloatValue extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode( $this->delimiter, $this->getParts() ); - } /** @@ -67,10 +63,9 @@ class FloatValue extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'FLOAT'; - } /** @@ -80,20 +75,19 @@ class FloatValue extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $val = array_map('floatval', $this->getParts()); // Special-casing the GEO property. // // See: // http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-04#section-3.4.1.2 - if ($this->name === 'GEO') { + if ('GEO' === $this->name) { return [$val]; } return $val; - } /** @@ -101,42 +95,32 @@ class FloatValue extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map('floatval', $value); parent::setXmlValue($value); - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { // Special-casing the GEO property. // // See: // http://tools.ietf.org/html/rfc6321#section-3.4.1.2 - if ($this->name === 'GEO') { - + if ('GEO' === $this->name) { $value = array_map('floatval', $this->getParts()); $writer->writeElement('latitude', $value[0]); $writer->writeElement('longitude', $value[1]); - - } - else { + } else { parent::xmlSerializeValue($writer); } - } - } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php b/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php index a0c4a9b9a..e89bb31f9 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php @@ -14,8 +14,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalAddress extends Text { - +class CalAddress extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,10 +32,9 @@ class CalAddress extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'CAL-ADDRESS'; - } /** @@ -48,14 +47,14 @@ class CalAddress extends Text { * * @return string */ - function getNormalizedValue() { - + public function getNormalizedValue() + { $input = $this->getValue(); if (!strpos($input, ':')) { return $input; } list($schema, $everythingElse) = explode(':', $input, 2); - return strtolower($schema) . ':' . $everythingElse; + return strtolower($schema).':'.$everythingElse; } } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Date.php b/vendor/sabre/vobject/lib/Property/ICalendar/Date.php index 378a0d60a..d8e86d13e 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Date.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Date.php @@ -13,6 +13,6 @@ namespace Sabre\VObject\Property\ICalendar; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Date extends DateTime { - +class Date extends DateTime +{ } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php index d580d4f68..7eb3e0bb7 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php @@ -24,8 +24,8 @@ use Sabre\VObject\TimeZoneUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateTime extends Property { - +class DateTime extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -40,17 +40,14 @@ class DateTime extends Property { * You may also specify DateTime objects here. * * @param array $parts - * - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { if (isset($parts[0]) && $parts[0] instanceof DateTimeInterface) { $this->setDateTimes($parts); } else { parent::setParts($parts); } - } /** @@ -61,11 +58,9 @@ class DateTime extends Property { * Instead of strings, you may also use DateTime here. * * @param string|array|DateTimeInterface $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { if (is_array($value) && isset($value[0]) && $value[0] instanceof DateTimeInterface) { $this->setDateTimes($value); } elseif ($value instanceof DateTimeInterface) { @@ -73,7 +68,6 @@ class DateTime extends Property { } else { parent::setValue($value); } - } /** @@ -83,13 +77,10 @@ class DateTime extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -97,10 +88,9 @@ class DateTime extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -108,10 +98,9 @@ class DateTime extends Property { * * @return bool */ - function hasTime() { - - return strtoupper((string)$this['VALUE']) !== 'DATE'; - + public function hasTime() + { + return 'DATE' !== strtoupper((string) $this['VALUE']); } /** @@ -119,15 +108,14 @@ class DateTime extends Property { * * Note that DATE is always floating. */ - function isFloating() { - + public function isFloating() + { return !$this->hasTime() || ( !isset($this['TZID']) && - strpos($this->getValue(), 'Z') === false + false === strpos($this->getValue(), 'Z') ); - } /** @@ -143,15 +131,16 @@ class DateTime extends Property { * * @param DateTimeZone $timeZone * - * @return DateTimeImmutable + * @return \DateTimeImmutable */ - function getDateTime(DateTimeZone $timeZone = null) { - + public function getDateTime(DateTimeZone $timeZone = null) + { $dt = $this->getDateTimes($timeZone); - if (!$dt) return; + if (!$dt) { + return; + } return $dt[0]; - } /** @@ -163,38 +152,35 @@ class DateTime extends Property { * * @param DateTimeZone $timeZone * - * @return DateTimeImmutable[] + * @return \DateTimeImmutable[] * @return \DateTime[] */ - function getDateTimes(DateTimeZone $timeZone = null) { - + public function getDateTimes(DateTimeZone $timeZone = null) + { // Does the property have a TZID? $tzid = $this['TZID']; if ($tzid) { - $timeZone = TimeZoneUtil::getTimeZone((string)$tzid, $this->root); + $timeZone = TimeZoneUtil::getTimeZone((string) $tzid, $this->root); } $dts = []; foreach ($this->getParts() as $part) { $dts[] = DateTimeParser::parse($part, $timeZone); } - return $dts; + return $dts; } /** * Sets the property as a DateTime object. * * @param DateTimeInterface $dt - * @param bool isFloating If set to true, timezones will be ignored. - * - * @return void + * @param bool isFloating If set to true, timezones will be ignored */ - function setDateTime(DateTimeInterface $dt, $isFloating = false) { - + public function setDateTime(DateTimeInterface $dt, $isFloating = false) + { $this->setDateTimes([$dt], $isFloating); - } /** @@ -204,21 +190,17 @@ class DateTime extends Property { * the otehr values will be adjusted for that timezone * * @param DateTimeInterface[] $dt - * @param bool isFloating If set to true, timezones will be ignored. - * - * @return void + * @param bool isFloating If set to true, timezones will be ignored */ - function setDateTimes(array $dt, $isFloating = false) { - + public function setDateTimes(array $dt, $isFloating = false) + { $values = []; if ($this->hasTime()) { - $tz = null; $isUtc = false; foreach ($dt as $d) { - if ($isFloating) { $values[] = $d->format('Ymd\\THis'); continue; @@ -238,25 +220,18 @@ class DateTime extends Property { } else { $values[] = $d->format('Ymd\\THis'); } - } if ($isUtc || $isFloating) { $this->offsetUnset('TZID'); } - } else { - foreach ($dt as $d) { - $values[] = $d->format('Ymd'); - } $this->offsetUnset('TZID'); - } $this->value = $values; - } /** @@ -267,10 +242,9 @@ class DateTime extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return $this->hasTime() ? 'DATE-TIME' : 'DATE'; - } /** @@ -280,8 +254,8 @@ class DateTime extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $dts = $this->getDateTimes(); $hasTime = $this->hasTime(); $isFloating = $this->isFloating(); @@ -290,18 +264,15 @@ class DateTime extends Property { $isUtc = $isFloating ? false : in_array($tz->getName(), ['UTC', 'GMT', 'Z']); return array_map( - function(DateTimeInterface $dt) use ($hasTime, $isUtc) { - + function (DateTimeInterface $dt) use ($hasTime, $isUtc) { if ($hasTime) { - return $dt->format('Y-m-d\\TH:i:s') . ($isUtc ? 'Z' : ''); + return $dt->format('Y-m-d\\TH:i:s').($isUtc ? 'Z' : ''); } else { return $dt->format('Y-m-d'); } - }, $dts ); - } /** @@ -310,26 +281,21 @@ class DateTime extends Property { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { // dates and times in jCal have one difference to dates and times in // iCalendar. In jCal date-parts are separated by dashes, and // time-parts are separated by colons. It makes sense to just remove // those. $this->setValue( array_map( - function($item) { - + function ($item) { return strtr($item, [':' => '', '-' => '']); - }, $value ) ); - } /** @@ -337,20 +303,17 @@ class DateTime extends Property { * VALUE from DATE-TIME to DATE or vice-versa. * * @param string $name - * @param mixed $value - * - * @return void + * @param mixed $value */ - function offsetSet($name, $value) { - + public function offsetSet($name, $value) + { parent::offsetSet($name, $value); - if (strtoupper($name) !== 'VALUE') { + if ('VALUE' !== strtoupper($name)) { return; } // This will ensure that dates are correctly encoded. $this->setDateTimes($this->getDateTimes()); - } /** @@ -375,30 +338,30 @@ class DateTime extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $messages = parent::validate($options); $valueType = $this->getValueType(); $values = $this->getParts(); try { foreach ($values as $value) { switch ($valueType) { - case 'DATE' : + case 'DATE': DateTimeParser::parseDate($value); break; - case 'DATE-TIME' : + case 'DATE-TIME': DateTimeParser::parseDateTime($value); break; } } } catch (InvalidDataException $e) { $messages[] = [ - 'level' => 3, - 'message' => 'The supplied value (' . $value . ') is not a correct ' . $valueType, - 'node' => $this, + 'level' => 3, + 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType, + 'node' => $this, ]; } - return $messages; + return $messages; } } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php b/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php index 7b7e1ce8e..87f008160 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php @@ -16,8 +16,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Duration extends Property { - +class Duration extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -33,13 +33,10 @@ class Duration extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -47,10 +44,9 @@ class Duration extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -61,10 +57,9 @@ class Duration extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DURATION'; - } /** @@ -74,12 +69,11 @@ class Duration extends Property { * * @return \DateInterval */ - function getDateInterval() { - + public function getDateInterval() + { $parts = $this->getParts(); $value = $parts[0]; - return DateTimeParser::parseDuration($value); + return DateTimeParser::parseDuration($value); } - } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Period.php b/vendor/sabre/vobject/lib/Property/ICalendar/Period.php index d35b425aa..17bfa5c5c 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Period.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Period.php @@ -17,8 +17,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Period extends Property { - +class Period extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -34,13 +34,10 @@ class Period extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -48,10 +45,9 @@ class Period extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -62,10 +58,9 @@ class Period extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'PERIOD'; - } /** @@ -74,21 +69,16 @@ class Period extends Property { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { $value = array_map( - function($item) { - + function ($item) { return strtr(implode('/', $item), [':' => '', '-' => '']); - }, $value ); parent::setJsonValue($value); - } /** @@ -98,20 +88,19 @@ class Period extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $return = []; foreach ($this->getParts() as $item) { - list($start, $end) = explode('/', $item, 2); $start = DateTimeParser::parseDateTime($start); // This is a duration value. - if ($end[0] === 'P') { + if ('P' === $end[0]) { $return[] = [ $start->format('Y-m-d\\TH:i:s'), - $end + $end, ]; } else { $end = DateTimeParser::parseDateTime($end); @@ -120,36 +109,29 @@ class Period extends Property { $end->format('Y-m-d\\TH:i:s'), ]; } - } return $return; - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $writer->startElement(strtolower($this->getValueType())); $value = $this->getJsonValue(); $writer->writeElement('start', $value[0][0]); - if ($value[0][1][0] === 'P') { + if ('P' === $value[0][1][0]) { $writer->writeElement('duration', $value[0][1]); - } - else { + } else { $writer->writeElement('end', $value[0][1]); } $writer->endElement(); - } - } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php b/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php index 434b77088..baeda781e 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php @@ -22,36 +22,33 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Recur extends Property { - +class Recur extends Property +{ /** * Updates the current value. * * This may be either a single, or multiple strings in an array. * * @param string|array $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { // If we're getting the data from json, we'll be receiving an object if ($value instanceof \StdClass) { - $value = (array)$value; + $value = (array) $value; } if (is_array($value)) { $newVal = []; foreach ($value as $k => $v) { - if (is_string($v)) { $v = strtoupper($v); // The value had multiple sub-values - if (strpos($v, ',') !== false) { + if (false !== strpos($v, ',')) { $v = explode(',', $v); } - if (strcmp($k, 'until') === 0) { + if (0 === strcmp($k, 'until')) { $v = strtr($v, [':' => '', '-' => '']); } } elseif (is_array($v)) { @@ -66,7 +63,6 @@ class Recur extends Property { } else { throw new \InvalidArgumentException('You must either pass a string, or a key=>value array'); } - } /** @@ -80,26 +76,24 @@ class Recur extends Property { * * @return string */ - function getValue() { - + public function getValue() + { $out = []; foreach ($this->value as $key => $value) { - $out[] = $key . '=' . (is_array($value) ? implode(',', $value) : $value); + $out[] = $key.'='.(is_array($value) ? implode(',', $value) : $value); } - return strtoupper(implode(';', $out)); + return strtoupper(implode(';', $out)); } /** * Sets a multi-valued property. * * @param array $parts - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { $this->setValue($parts); - } /** @@ -110,10 +104,9 @@ class Recur extends Property { * * @return array */ - function getParts() { - + public function getParts() + { return $this->value; - } /** @@ -123,13 +116,10 @@ class Recur extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue($val); - } /** @@ -137,10 +127,9 @@ class Recur extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->getValue(); - } /** @@ -151,10 +140,9 @@ class Recur extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'RECUR'; - } /** @@ -164,39 +152,36 @@ class Recur extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $values = []; foreach ($this->getParts() as $k => $v) { - if (strcmp($k, 'UNTIL') === 0) { + if (0 === strcmp($k, 'UNTIL')) { $date = new DateTime($this->root, null, $v); $values[strtolower($k)] = $date->getJsonValue()[0]; - } elseif (strcmp($k, 'COUNT') === 0) { + } elseif (0 === strcmp($k, 'COUNT')) { $values[strtolower($k)] = intval($v); } else { $values[strtolower($k)] = $v; } } - return [$values]; + return [$values]; } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $valueType = strtolower($this->getValueType()); foreach ($this->getJsonValue() as $value) { $writer->writeElement($valueType, $value); } - } /** @@ -206,12 +191,11 @@ class Recur extends Property { * * @return array */ - static function stringToArray($value) { - + public static function stringToArray($value) + { $value = strtoupper($value); $newValue = []; foreach (explode(';', $value) as $part) { - // Skipping empty parts. if (empty($part)) { continue; @@ -219,11 +203,10 @@ class Recur extends Property { list($partName, $partValue) = explode('=', $part); // The value itself had multiple values.. - if (strpos($partValue, ',') !== false) { + if (false !== strpos($partValue, ',')) { $partValue = explode(',', $partValue); } $newValue[$partName] = $partValue; - } return $newValue; @@ -251,32 +234,31 @@ class Recur extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $repair = ($options & self::REPAIR); $warnings = parent::validate($options); $values = $this->getParts(); foreach ($values as $key => $value) { - - if ($value === '') { + if ('' === $value) { $warnings[] = [ - 'level' => $repair ? 1 : 3, - 'message' => 'Invalid value for ' . $key . ' in ' . $this->name, - 'node' => $this + 'level' => $repair ? 1 : 3, + 'message' => 'Invalid value for '.$key.' in '.$this->name, + 'node' => $this, ]; if ($repair) { unset($values[$key]); } - } elseif ($key == 'BYMONTH') { - $byMonth = (array)$value; + } elseif ('BYMONTH' == $key) { + $byMonth = (array) $value; foreach ($byMonth as $i => $v) { - if (!is_numeric($v) || (int)$v < 1 || (int)$v > 12) { + if (!is_numeric($v) || (int) $v < 1 || (int) $v > 12) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYMONTH in RRULE must have value(s) between 1 and 12!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -291,14 +273,14 @@ class Recur extends Property { if (is_array($value) && empty($values[$key])) { unset($values[$key]); } - } elseif ($key == 'BYWEEKNO') { - $byWeekNo = (array)$value; + } elseif ('BYWEEKNO' == $key) { + $byWeekNo = (array) $value; foreach ($byWeekNo as $i => $v) { - if (!is_numeric($v) || (int)$v < -53 || (int)$v == 0 || (int)$v > 53) { + if (!is_numeric($v) || (int) $v < -53 || 0 == (int) $v || (int) $v > 53) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -313,14 +295,14 @@ class Recur extends Property { if (is_array($value) && empty($values[$key])) { unset($values[$key]); } - } elseif ($key == 'BYYEARDAY') { - $byYearDay = (array)$value; + } elseif ('BYYEARDAY' == $key) { + $byYearDay = (array) $value; foreach ($byYearDay as $i => $v) { - if (!is_numeric($v) || (int)$v < -366 || (int)$v == 0 || (int)$v > 366) { + if (!is_numeric($v) || (int) $v < -366 || 0 == (int) $v || (int) $v > 366) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -336,13 +318,12 @@ class Recur extends Property { unset($values[$key]); } } - } if (!isset($values['FREQ'])) { $warnings[] = [ - 'level' => $repair ? 1 : 3, - 'message' => 'FREQ is required in ' . $this->name, - 'node' => $this + 'level' => $repair ? 1 : 3, + 'message' => 'FREQ is required in '.$this->name, + 'node' => $this, ]; if ($repair) { $this->parent->remove($this); @@ -353,7 +334,5 @@ class Recur extends Property { } return $warnings; - } - } diff --git a/vendor/sabre/vobject/lib/Property/IntegerValue.php b/vendor/sabre/vobject/lib/Property/IntegerValue.php index 5bd1887fa..ddd71d731 100644 --- a/vendor/sabre/vobject/lib/Property/IntegerValue.php +++ b/vendor/sabre/vobject/lib/Property/IntegerValue.php @@ -15,8 +15,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class IntegerValue extends Property { - +class IntegerValue extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -24,13 +24,10 @@ class IntegerValue extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - - $this->setValue((int)$val); - + public function setRawMimeDirValue($val) + { + $this->setValue((int) $val); } /** @@ -38,10 +35,9 @@ class IntegerValue extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->value; - } /** @@ -52,10 +48,9 @@ class IntegerValue extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'INTEGER'; - } /** @@ -65,10 +60,9 @@ class IntegerValue extends Property { * * @return array */ - function getJsonValue() { - - return [(int)$this->getValue()]; - + public function getJsonValue() + { + return [(int) $this->getValue()]; } /** @@ -76,13 +70,10 @@ class IntegerValue extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map('intval', $value); parent::setXmlValue($value); - } } diff --git a/vendor/sabre/vobject/lib/Property/Text.php b/vendor/sabre/vobject/lib/Property/Text.php index 47a86ccc9..23c945551 100644 --- a/vendor/sabre/vobject/lib/Property/Text.php +++ b/vendor/sabre/vobject/lib/Property/Text.php @@ -17,8 +17,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Text extends Property { - +class Text extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -53,7 +53,7 @@ class Text extends Property { * @var array */ protected $minimumPropertyValues = [ - 'N' => 5, + 'N' => 5, 'ADR' => 7, ]; @@ -64,16 +64,14 @@ class Text extends Property { * parameters will automatically be created, or you can just pass a list of * Parameter objects. * - * @param Component $root The root document - * @param string $name + * @param Component $root The root document + * @param string $name * @param string|array|null $value - * @param array $parameters List of parameters - * @param string $group The vcard property group - * - * @return void + * @param array $parameters List of parameters + * @param string $group The vcard property group */ - function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) { - + public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) + { // There's two types of multi-valued text properties: // 1. multivalue properties. // 2. structured value properties @@ -84,7 +82,6 @@ class Text extends Property { } parent::__construct($root, $name, $value, $parameters, $group); - } /** @@ -94,24 +91,19 @@ class Text extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(MimeDir::unescapeValue($val, $this->delimiter)); - } /** * Sets the value as a quoted-printable encoded string. * * @param string $val - * - * @return void */ - function setQuotedPrintableValue($val) { - + public function setQuotedPrintableValue($val) + { $val = quoted_printable_decode($val); // Quoted printable only appears in vCard 2.1, and the only character @@ -123,7 +115,6 @@ class Text extends Property { $regex = '# (?<!\\\\) ; #x'; $matches = preg_split($regex, $val); $this->setValue($matches); - } /** @@ -131,8 +122,8 @@ class Text extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { $val = $this->getParts(); if (isset($this->minimumPropertyValues[$this->name])) { @@ -140,7 +131,6 @@ class Text extends Property { } foreach ($val as &$item) { - if (!is_array($item)) { $item = [$item]; } @@ -150,19 +140,17 @@ class Text extends Property { $subItem, [ '\\' => '\\\\', - ';' => '\;', - ',' => '\,', + ';' => '\;', + ',' => '\,', "\n" => '\n', - "\r" => "", + "\r" => '', ] ); } $item = implode(',', $item); - } return implode($this->delimiter, $val); - } /** @@ -172,16 +160,16 @@ class Text extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { // Structured text values should always be returned as a single // array-item. Multi-value text should be returned as multiple items in // the top-array. if (in_array($this->name, $this->structuredValues)) { return [$this->getParts()]; } - return $this->getParts(); + return $this->getParts(); } /** @@ -192,10 +180,9 @@ class Text extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TEXT'; - } /** @@ -203,10 +190,10 @@ class Text extends Property { * * @return string */ - function serialize() { - + public function serialize() + { // We need to kick in a special type of encoding, if it's a 2.1 vcard. - if ($this->root->getDocumentType() !== Document::VCARD21) { + if (Document::VCARD21 !== $this->root->getDocumentType()) { return parent::serialize(); } @@ -228,22 +215,19 @@ class Text extends Property { } $str = $this->name; - if ($this->group) $str = $this->group . '.' . $this->name; + if ($this->group) { + $str = $this->group.'.'.$this->name; + } foreach ($this->parameters as $param) { - - if ($param->getValue() === 'QUOTED-PRINTABLE') { + if ('QUOTED-PRINTABLE' === $param->getValue()) { continue; } - $str .= ';' . $param->serialize(); - + $str .= ';'.$param->serialize(); } - - // If the resulting value contains a \n, we must encode it as // quoted-printable. - if (\strpos($val, "\n") !== false) { - + if (false !== \strpos($val, "\n")) { $str .= ';ENCODING=QUOTED-PRINTABLE:'; $lastLine = $str; $out = null; @@ -252,26 +236,27 @@ class Text extends Property { // encode newlines for us. Specifically, the \r\n sequence must in // vcards be encoded as =0D=OA and we must insert soft-newlines // every 75 bytes. - for ($ii = 0;$ii < \strlen($val);$ii++) { + for ($ii = 0; $ii < \strlen($val); ++$ii) { $ord = \ord($val[$ii]); // These characters are encoded as themselves. if ($ord >= 32 && $ord <= 126) { $lastLine .= $val[$ii]; } else { - $lastLine .= '=' . \strtoupper(\bin2hex($val[$ii])); + $lastLine .= '='.\strtoupper(\bin2hex($val[$ii])); } if (\strlen($lastLine) >= 75) { // Soft line break - $out .= $lastLine . "=\r\n "; + $out .= $lastLine."=\r\n "; $lastLine = null; } - } - if (!\is_null($lastLine)) $out .= $lastLine . "\r\n"; - return $out; + if (!\is_null($lastLine)) { + $out .= $lastLine."\r\n"; + } + return $out; } else { - $str .= ':' . $val; + $str .= ':'.$val; $str = \preg_replace( '/( @@ -285,24 +270,20 @@ class Text extends Property { // remove single space after last CRLF return \substr($str, 0, -1); - } - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $values = $this->getParts(); - $map = function($items) use ($values, $writer) { + $map = function ($items) use ($values, $writer) { foreach ($items as $i => $item) { $writer->writeElement( $item, @@ -312,7 +293,6 @@ class Text extends Property { }; switch ($this->name) { - // Special-casing the REQUEST-STATUS property. // // See: @@ -332,14 +312,14 @@ class Text extends Property { 'given', 'additional', 'prefix', - 'suffix' + 'suffix', ]); break; case 'GENDER': $map([ 'sex', - 'text' + 'text', ]); break; @@ -351,21 +331,20 @@ class Text extends Property { 'locality', 'region', 'code', - 'country' + 'country', ]); break; case 'CLIENTPIDMAP': $map([ 'sourceid', - 'uri' + 'uri', ]); break; default: parent::xmlSerializeValue($writer); } - } /** @@ -386,28 +365,26 @@ class Text extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $warnings = parent::validate($options); if (isset($this->minimumPropertyValues[$this->name])) { - $minimum = $this->minimumPropertyValues[$this->name]; $parts = $this->getParts(); if (count($parts) < $minimum) { $warnings[] = [ - 'level' => $options & self::REPAIR ? 1 : 3, - 'message' => 'The ' . $this->name . ' property must have at least ' . $minimum . ' values. It only has ' . count($parts), - 'node' => $this, + 'level' => $options & self::REPAIR ? 1 : 3, + 'message' => 'The '.$this->name.' property must have at least '.$minimum.' values. It only has '.count($parts), + 'node' => $this, ]; if ($options & self::REPAIR) { $parts = array_pad($parts, $minimum, ''); $this->setParts($parts); } } - } - return $warnings; + return $warnings; } } diff --git a/vendor/sabre/vobject/lib/Property/Time.php b/vendor/sabre/vobject/lib/Property/Time.php index dbafc3b85..7aeafc8d0 100644 --- a/vendor/sabre/vobject/lib/Property/Time.php +++ b/vendor/sabre/vobject/lib/Property/Time.php @@ -13,8 +13,8 @@ use Sabre\VObject\DateTimeParser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Time extends Text { - +class Time extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -31,10 +31,9 @@ class Time extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TIME'; - } /** @@ -43,11 +42,9 @@ class Time extends Text { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { // Removing colons from value. $value = str_replace( ':', @@ -55,12 +52,11 @@ class Time extends Text { $value ); - if (count($value) === 1) { + if (1 === count($value)) { $this->setValue(reset($value)); } else { $this->setValue($value); } - } /** @@ -70,8 +66,8 @@ class Time extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardTime($this->getValue()); $timeStr = ''; @@ -109,7 +105,7 @@ class Time extends Text { // Timezone if (!is_null($parts['timezone'])) { - if ($parts['timezone'] === 'Z') { + if ('Z' === $parts['timezone']) { $timeStr .= 'Z'; } else { $timeStr .= @@ -118,7 +114,6 @@ class Time extends Text { } return [$timeStr]; - } /** @@ -126,19 +121,15 @@ class Time extends Text { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map( - function($value) { + function ($value) { return str_replace(':', '', $value); }, $value ); parent::setXmlValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/Unknown.php b/vendor/sabre/vobject/lib/Property/Unknown.php index 7a3373868..6f404c286 100644 --- a/vendor/sabre/vobject/lib/Property/Unknown.php +++ b/vendor/sabre/vobject/lib/Property/Unknown.php @@ -12,8 +12,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Unknown extends Text { - +class Unknown extends Text +{ /** * Returns the value, in the format it should be encoded for json. * @@ -21,10 +21,9 @@ class Unknown extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return [$this->getRawMimeDirValue()]; - } /** @@ -35,10 +34,8 @@ class Unknown extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'UNKNOWN'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/Uri.php b/vendor/sabre/vobject/lib/Property/Uri.php index 88fcfaab8..3449ba1f2 100644 --- a/vendor/sabre/vobject/lib/Property/Uri.php +++ b/vendor/sabre/vobject/lib/Property/Uri.php @@ -14,8 +14,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Uri extends Text { - +class Uri extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,10 +32,9 @@ class Uri extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'URI'; - } /** @@ -43,8 +42,8 @@ class Uri extends Text { * * @return array */ - function parameters() { - + public function parameters() + { $parameters = parent::parameters(); if (!isset($parameters['VALUE']) && in_array($this->name, ['URL', 'PHOTO'])) { // If we are encoding a URI value, and this URI value has no @@ -57,8 +56,8 @@ class Uri extends Text { // See Issue #227 and #235 $parameters['VALUE'] = new Parameter($this->root, 'VALUE', 'URI'); } - return $parameters; + return $parameters; } /** @@ -68,11 +67,9 @@ class Uri extends Text { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { // Normally we don't need to do any type of unescaping for these // properties, however.. we've noticed that Google Contacts // specifically escapes the colon (:) with a blackslash. While I have @@ -81,16 +78,16 @@ class Uri extends Text { // // Good thing backslashes are not allowed in urls. Makes it easy to // assume that a backslash is always intended as an escape character. - if ($this->name === 'URL') { + if ('URL' === $this->name) { $regex = '# (?: (\\\\ (?: \\\\ | : ) ) ) #x'; $matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $newVal = ''; foreach ($matches as $match) { switch ($match) { - case '\:' : + case '\:': $newVal .= ':'; break; - default : + default: $newVal .= $match; break; } @@ -99,7 +96,6 @@ class Uri extends Text { } else { $this->value = strtr($val, ['\,' => ',']); } - } /** @@ -107,8 +103,8 @@ class Uri extends Text { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { if (is_array($this->value)) { $value = $this->value[0]; } else { @@ -116,7 +112,5 @@ class Uri extends Text { } return strtr($value, [',' => '\,']); - } - } diff --git a/vendor/sabre/vobject/lib/Property/UtcOffset.php b/vendor/sabre/vobject/lib/Property/UtcOffset.php index 61895c48e..732239e23 100644 --- a/vendor/sabre/vobject/lib/Property/UtcOffset.php +++ b/vendor/sabre/vobject/lib/Property/UtcOffset.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UtcOffset extends Text { - +class UtcOffset extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -29,10 +29,9 @@ class UtcOffset extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'UTC-OFFSET'; - } /** @@ -41,19 +40,16 @@ class UtcOffset extends Text { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { $value = array_map( - function($value) { + function ($value) { return str_replace(':', '', $value); }, $value ); parent::setJsonValue($value); - } /** @@ -63,15 +59,14 @@ class UtcOffset extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return array_map( - function($value) { - return substr($value, 0, -2) . ':' . + function ($value) { + return substr($value, 0, -2).':'. substr($value, -2); }, parent::getJsonValue() ); - } } diff --git a/vendor/sabre/vobject/lib/Property/VCard/Date.php b/vendor/sabre/vobject/lib/Property/VCard/Date.php index 1ef6dff34..a018ccbb8 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/Date.php +++ b/vendor/sabre/vobject/lib/Property/VCard/Date.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property\VCard; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Date extends DateAndOrTime { - +class Date extends DateAndOrTime +{ /** * Returns the type of value. * @@ -21,23 +21,18 @@ class Date extends DateAndOrTime { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE'; - } /** * Sets the property as a DateTime object. * * @param \DateTimeInterface $dt - * - * @return void */ - function setDateTime(\DateTimeInterface $dt) { - + public function setDateTime(\DateTimeInterface $dt) + { $this->value = $dt->format('Ymd'); - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php b/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php index 3b4ae3bb5..b7e17492a 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php +++ b/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php @@ -19,12 +19,12 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateAndOrTime extends Property { - +class DateAndOrTime extends Property +{ /** * Field separator. * - * @var null|string + * @var string|null */ public $delimiter = null; @@ -36,10 +36,9 @@ class DateAndOrTime extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE-AND-OR-TIME'; - } /** @@ -48,11 +47,9 @@ class DateAndOrTime extends Property { * You may also specify DateTimeInterface objects here. * * @param array $parts - * - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { if (count($parts) > 1) { throw new \InvalidArgumentException('Only one value allowed'); } @@ -61,7 +58,6 @@ class DateAndOrTime extends Property { } else { parent::setParts($parts); } - } /** @@ -72,28 +68,23 @@ class DateAndOrTime extends Property { * Instead of strings, you may also use DateTimeInterface here. * * @param string|array|DateTimeInterface $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { if ($value instanceof DateTimeInterface) { $this->setDateTime($value); } else { parent::setValue($value); } - } /** * Sets the property as a DateTime object. * * @param DateTimeInterface $dt - * - * @return void */ - function setDateTime(DateTimeInterface $dt) { - + public function setDateTime(DateTimeInterface $dt) + { $tz = $dt->getTimeZone(); $isUtc = in_array($tz->getName(), ['UTC', 'GMT', 'Z']); @@ -105,7 +96,6 @@ class DateAndOrTime extends Property { } $this->value = $value; - } /** @@ -124,12 +114,12 @@ class DateAndOrTime extends Property { * * @return DateTimeImmutable */ - function getDateTime() { - + public function getDateTime() + { $now = new DateTime(); - $tzFormat = $now->getTimezone()->getOffset($now) === 0 ? '\\Z' : 'O'; - $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This' . $tzFormat)); + $tzFormat = 0 === $now->getTimezone()->getOffset($now) ? '\\Z' : 'O'; + $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This'.$tzFormat)); $dateParts = DateTimeParser::parseVCardDateTime($this->getValue()); @@ -141,8 +131,8 @@ class DateAndOrTime extends Property { $dateParts[$k] = $nowParts[$k]; } } - return new DateTimeImmutable("$dateParts[year]-$dateParts[month]-$dateParts[date] $dateParts[hour]:$dateParts[minute]:$dateParts[second] $dateParts[timezone]"); + return new DateTimeImmutable("$dateParts[year]-$dateParts[month]-$dateParts[date] $dateParts[hour]:$dateParts[minute]:$dateParts[second] $dateParts[timezone]"); } /** @@ -152,15 +142,14 @@ class DateAndOrTime extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardDateTime($this->getValue()); $dateStr = ''; // Year if (!is_null($parts['year'])) { - $dateStr .= $parts['year']; if (!is_null($parts['month'])) { @@ -168,26 +157,21 @@ class DateAndOrTime extends Property { // dash. $dateStr .= '-'; } - } else { - if (!is_null($parts['month']) || !is_null($parts['date'])) { // Inserting two dashes $dateStr .= '--'; } - } // Month if (!is_null($parts['month'])) { - $dateStr .= $parts['month']; if (isset($parts['date'])) { // If month and date are set, we need the separator dash. $dateStr .= '-'; } - } elseif (isset($parts['date'])) { // If the month is empty, and a date is set, we need a 'empty // dash' @@ -199,7 +183,6 @@ class DateAndOrTime extends Property { $dateStr .= $parts['date']; } - // Early exit if we don't have a time string. if (is_null($parts['hour']) && is_null($parts['minute']) && is_null($parts['second'])) { return [$dateStr]; @@ -209,13 +192,11 @@ class DateAndOrTime extends Property { // Hour if (!is_null($parts['hour'])) { - $dateStr .= $parts['hour']; if (!is_null($parts['minute'])) { $dateStr .= ':'; } - } else { // We know either minute or second _must_ be set, so we insert a // dash for an empty value. @@ -224,13 +205,11 @@ class DateAndOrTime extends Property { // Minute if (!is_null($parts['minute'])) { - $dateStr .= $parts['minute']; if (!is_null($parts['second'])) { $dateStr .= ':'; } - } elseif (isset($parts['second'])) { // Dash for empty minute $dateStr .= '-'; @@ -247,30 +226,27 @@ class DateAndOrTime extends Property { } return [$dateStr]; - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $valueType = strtolower($this->getValueType()); $parts = DateTimeParser::parseVCardDateAndOrTime($this->getValue()); $value = ''; // $d = defined - $d = function($part) use ($parts) { + $d = function ($part) use ($parts) { return !is_null($parts[$part]); }; // $r = read - $r = function($part) use ($parts) { + $r = function ($part) use ($parts) { return $parts[$part]; }; @@ -282,31 +258,29 @@ class DateAndOrTime extends Property { // } if (($d('year') || $d('month') || $d('date')) && (!$d('hour') && !$d('minute') && !$d('second') && !$d('timezone'))) { - if ($d('year') && $d('month') && $d('date')) { - $value .= $r('year') . $r('month') . $r('date'); + $value .= $r('year').$r('month').$r('date'); } elseif ($d('year') && $d('month') && !$d('date')) { - $value .= $r('year') . '-' . $r('month'); + $value .= $r('year').'-'.$r('month'); } elseif (!$d('year') && $d('month')) { - $value .= '--' . $r('month') . $r('date'); + $value .= '--'.$r('month').$r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { - $value .= '---' . $r('date'); + $value .= '---'.$r('date'); } - // # 4.3.2 + // # 4.3.2 // value-time = element time { // xsd:string { pattern = "(\d\d(\d\d(\d\d)?)?|-\d\d(\d\d?)|--\d\d)" // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif ((!$d('year') && !$d('month') && !$d('date')) && ($d('hour') || $d('minute') || $d('second'))) { - if ($d('hour')) { - $value .= $r('hour') . $r('minute') . $r('second'); + $value .= $r('hour').$r('minute').$r('second'); } elseif ($d('minute')) { - $value .= '-' . $r('minute') . $r('second'); + $value .= '-'.$r('minute').$r('second'); } elseif ($d('second')) { - $value .= '--' . $r('second'); + $value .= '--'.$r('second'); } $value .= $r('timezone'); @@ -317,22 +291,19 @@ class DateAndOrTime extends Property { // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif ($d('date') && $d('hour')) { - if ($d('year') && $d('month') && $d('date')) { - $value .= $r('year') . $r('month') . $r('date'); + $value .= $r('year').$r('month').$r('date'); } elseif (!$d('year') && $d('month') && $d('date')) { - $value .= '--' . $r('month') . $r('date'); + $value .= '--'.$r('month').$r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { - $value .= '---' . $r('date'); + $value .= '---'.$r('date'); } - $value .= 'T' . $r('hour') . $r('minute') . $r('second') . + $value .= 'T'.$r('hour').$r('minute').$r('second'). $r('timezone'); - } $writer->writeElement($valueType, $value); - } /** @@ -342,13 +313,10 @@ class DateAndOrTime extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue($val); - } /** @@ -356,10 +324,9 @@ class DateAndOrTime extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -384,8 +351,8 @@ class DateAndOrTime extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $messages = parent::validate($options); $value = $this->getValue(); @@ -393,13 +360,12 @@ class DateAndOrTime extends Property { DateTimeParser::parseVCardDateTime($value); } catch (InvalidDataException $e) { $messages[] = [ - 'level' => 3, - 'message' => 'The supplied value (' . $value . ') is not a correct DATE-AND-OR-TIME property', - 'node' => $this, + 'level' => 3, + 'message' => 'The supplied value ('.$value.') is not a correct DATE-AND-OR-TIME property', + 'node' => $this, ]; } return $messages; - } } diff --git a/vendor/sabre/vobject/lib/Property/VCard/DateTime.php b/vendor/sabre/vobject/lib/Property/VCard/DateTime.php index e7c804ca7..49c1f3555 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/DateTime.php +++ b/vendor/sabre/vobject/lib/Property/VCard/DateTime.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property\VCard; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateTime extends DateAndOrTime { - +class DateTime extends DateAndOrTime +{ /** * Returns the type of value. * @@ -21,10 +21,8 @@ class DateTime extends DateAndOrTime { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE-TIME'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php b/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php index aa7e9178d..697273989 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php +++ b/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php @@ -14,8 +14,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LanguageTag extends Property { - +class LanguageTag extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -23,13 +23,10 @@ class LanguageTag extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue($val); - } /** @@ -37,10 +34,9 @@ class LanguageTag extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->getValue(); - } /** @@ -51,10 +47,8 @@ class LanguageTag extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'LANGUAGE-TAG'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php b/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php index 9d311f99d..fccf2d600 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php +++ b/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TimeStamp extends Text { - +class TimeStamp extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -33,10 +33,9 @@ class TimeStamp extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TIMESTAMP'; - } /** @@ -46,16 +45,16 @@ class TimeStamp extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardDateTime($this->getValue()); $dateStr = - $parts['year'] . '-' . - $parts['month'] . '-' . - $parts['date'] . 'T' . - $parts['hour'] . ':' . - $parts['minute'] . ':' . + $parts['year'].'-'. + $parts['month'].'-'. + $parts['date'].'T'. + $parts['hour'].':'. + $parts['minute'].':'. $parts['second']; // Timezone @@ -64,23 +63,19 @@ class TimeStamp extends Text { } return [$dateStr]; - } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { // xCard is the only XML and JSON format that has the same date and time // format than vCard. $valueType = strtolower($this->getValueType()); $writer->writeElement($valueType, $this->getValue()); - } } diff --git a/vendor/sabre/vobject/lib/Reader.php b/vendor/sabre/vobject/lib/Reader.php index 709929337..055d546a5 100644 --- a/vendor/sabre/vobject/lib/Reader.php +++ b/vendor/sabre/vobject/lib/Reader.php @@ -12,8 +12,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Reader { - +class Reader +{ /** * If this option is passed to the reader, it will be less strict about the * validity of the lines. @@ -35,18 +35,18 @@ class Reader { * You can either supply a string, or a readable stream for input. * * @param string|resource $data - * @param int $options - * @param string $charset + * @param int $options + * @param string $charset + * * @return Document */ - static function read($data, $options = 0, $charset = 'UTF-8') { - + public static function read($data, $options = 0, $charset = 'UTF-8') + { $parser = new Parser\MimeDir(); $parser->setCharset($charset); $result = $parser->parse($data, $options); return $result; - } /** @@ -55,22 +55,21 @@ class Reader { * The options argument is a bitfield. Pass any of the OPTIONS constant to * alter the parsers' behaviour. * - * You can either a string, a readable stream, or an array for it's input. + * You can either a string, a readable stream, or an array for its input. * Specifying the array is useful if json_decode was already called on the * input. * * @param string|resource|array $data - * @param int $options + * @param int $options * * @return Document */ - static function readJson($data, $options = 0) { - + public static function readJson($data, $options = 0) + { $parser = new Parser\Json(); $result = $parser->parse($data, $options); return $result; - } /** @@ -82,17 +81,15 @@ class Reader { * You can either supply a string, or a readable stream for input. * * @param string|resource $data - * @param int $options + * @param int $options * * @return Document */ - static function readXML($data, $options = 0) { - + public static function readXML($data, $options = 0) + { $parser = new Parser\XML(); $result = $parser->parse($data, $options); return $result; - } - } diff --git a/vendor/sabre/vobject/lib/Recur/EventIterator.php b/vendor/sabre/vobject/lib/Recur/EventIterator.php index d313305a0..135ecf00e 100644 --- a/vendor/sabre/vobject/lib/Recur/EventIterator.php +++ b/vendor/sabre/vobject/lib/Recur/EventIterator.php @@ -58,8 +58,8 @@ use Sabre\VObject\Settings; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class EventIterator implements \Iterator { - +class EventIterator implements \Iterator +{ /** * Reference timeZone for floating dates and times. * @@ -89,12 +89,12 @@ class EventIterator implements \Iterator { * The $uid parameter is only required for the first method. * * @param Component|array $input - * @param string|null $uid - * @param DateTimeZone $timeZone Reference timezone for floating dates and - * times. + * @param string|null $uid + * @param DateTimeZone $timeZone reference timezone for floating dates and + * times */ - function __construct($input, $uid = null, DateTimeZone $timeZone = null) { - + public function __construct($input, $uid = null, DateTimeZone $timeZone = null) + { if (is_null($timeZone)) { $timeZone = new DateTimeZone('UTC'); } @@ -107,7 +107,7 @@ class EventIterator implements \Iterator { $events = [$input]; } else { // Calendar + UID mode. - $uid = (string)$uid; + $uid = (string) $uid; if (!$uid) { throw new InvalidArgumentException('The UID argument is required when a VCALENDAR is passed to this constructor'); } @@ -115,24 +115,17 @@ class EventIterator implements \Iterator { throw new InvalidArgumentException('No events found in this calendar'); } $events = $input->getByUID($uid); - } foreach ($events as $vevent) { - if (!isset($vevent->{'RECURRENCE-ID'})) { - $this->masterEvent = $vevent; - } else { - $this->exceptions[ $vevent->{'RECURRENCE-ID'}->getDateTime($this->timeZone)->getTimeStamp() ] = true; $this->overriddenEvents[] = $vevent; - } - } if (!$this->masterEvent) { @@ -143,7 +136,7 @@ class EventIterator implements \Iterator { // event and use that instead. This may not always give the // desired result. if (!count($this->overriddenEvents)) { - throw new InvalidArgumentException('This VCALENDAR did not have an event with UID: ' . $uid); + throw new InvalidArgumentException('This VCALENDAR did not have an event with UID: '.$uid); } $this->masterEvent = array_shift($this->overriddenEvents); } @@ -152,15 +145,11 @@ class EventIterator implements \Iterator { $this->allDay = !$this->masterEvent->DTSTART->hasTime(); if (isset($this->masterEvent->EXDATE)) { - foreach ($this->masterEvent->EXDATE as $exDate) { - foreach ($exDate->getDateTimes($this->timeZone) as $dt) { $this->exceptions[$dt->getTimeStamp()] = true; } - } - } if (isset($this->masterEvent->DTEND)) { @@ -191,7 +180,7 @@ class EventIterator implements \Iterator { } else { $this->recurIterator = new RRuleIterator( [ - 'FREQ' => 'DAILY', + 'FREQ' => 'DAILY', 'COUNT' => 1, ], $this->startDate @@ -202,7 +191,6 @@ class EventIterator implements \Iterator { if (!$this->valid()) { throw new NoInstancesException('This recurrence rule does not generate any valid instances'); } - } /** @@ -210,12 +198,11 @@ class EventIterator implements \Iterator { * * @return DateTimeImmutable */ - function current() { - + public function current() + { if ($this->currentDate) { return clone $this->currentDate; } - } /** @@ -224,12 +211,11 @@ class EventIterator implements \Iterator { * * @return DateTimeImmutable */ - function getDtStart() { - + public function getDtStart() + { if ($this->currentDate) { return clone $this->currentDate; } - } /** @@ -238,26 +224,26 @@ class EventIterator implements \Iterator { * * @return DateTimeImmutable */ - function getDtEnd() { - + public function getDtEnd() + { if (!$this->valid()) { return; } $end = clone $this->currentDate; - return $end->modify('+' . $this->eventDuration . ' seconds'); + return $end->modify('+'.$this->eventDuration.' seconds'); } /** * Returns a VEVENT for the current iterations of the event. * - * This VEVENT will have a recurrence id, and it's DTSTART and DTEND + * This VEVENT will have a recurrence id, and its DTSTART and DTEND * altered. * * @return VEvent */ - function getEventObject() { - + public function getEventObject() + { if ($this->currentOverriddenEvent) { return $this->currentOverriddenEvent; } @@ -284,8 +270,8 @@ class EventIterator implements \Iterator { $recurid = clone $event->DTSTART; $recurid->name = 'RECURRENCE-ID'; $event->add($recurid); - return $event; + return $event; } /** @@ -295,11 +281,10 @@ class EventIterator implements \Iterator { * * @return int */ - function key() { - + public function key() + { // The counter is always 1 ahead. return $this->counter - 1; - } /** @@ -308,20 +293,20 @@ class EventIterator implements \Iterator { * * @return bool */ - function valid() { - - if ($this->counter > Settings::$maxRecurrences && Settings::$maxRecurrences !== -1) { - throw new MaxInstancesExceededException('Recurring events are only allowed to generate ' . Settings::$maxRecurrences); + public function valid() + { + if ($this->counter > Settings::$maxRecurrences && -1 !== Settings::$maxRecurrences) { + throw new MaxInstancesExceededException('Recurring events are only allowed to generate '.Settings::$maxRecurrences); } - return !!$this->currentDate; + return (bool) $this->currentDate; } /** * Sets the iterator back to the starting point. */ - function rewind() { - + public function rewind() + { $this->recurIterator->rewind(); // re-creating overridden event index. $index = []; @@ -338,18 +323,15 @@ class EventIterator implements \Iterator { $this->currentDate = clone $this->startDate; $this->next(); - } /** * Advances the iterator with one step. - * - * @return void */ - function next() { - + public function next() + { $this->currentOverriddenEvent = null; - $this->counter++; + ++$this->counter; if ($this->nextDate) { // We had a stored value. $nextDate = $this->nextDate; @@ -366,14 +348,11 @@ class EventIterator implements \Iterator { $nextDate = $this->recurIterator->current(); $this->recurIterator->next(); } while (isset($this->exceptions[$nextDate->getTimeStamp()])); - } - // $nextDate now contains what rrule thinks is the next one, but an // overridden event may cut ahead. if ($this->overriddenEventsIndex) { - $offsets = end($this->overriddenEventsIndex); $timestamp = key($this->overriddenEventsIndex); $offset = end($offsets); @@ -393,13 +372,10 @@ class EventIterator implements \Iterator { // Exit point! return; - } - } $this->currentDate = $nextDate; - } /** @@ -407,12 +383,11 @@ class EventIterator implements \Iterator { * * @param DateTimeInterface $dateTime */ - function fastForward(DateTimeInterface $dateTime) { - + public function fastForward(DateTimeInterface $dateTime) + { while ($this->valid() && $this->getDtEnd() <= $dateTime) { $this->next(); } - } /** @@ -420,10 +395,9 @@ class EventIterator implements \Iterator { * * @return bool */ - function isInfinite() { - + public function isInfinite() + { return $this->recurIterator->isInfinite(); - } /** @@ -504,10 +478,9 @@ class EventIterator implements \Iterator { protected $nextDate; /** - * The event that overwrites the current iteration + * The event that overwrites the current iteration. * * @var VEVENT */ protected $currentOverriddenEvent; - } diff --git a/vendor/sabre/vobject/lib/Recur/MaxInstancesExceededException.php b/vendor/sabre/vobject/lib/Recur/MaxInstancesExceededException.php index 264df7d2b..cb0835813 100644 --- a/vendor/sabre/vobject/lib/Recur/MaxInstancesExceededException.php +++ b/vendor/sabre/vobject/lib/Recur/MaxInstancesExceededException.php @@ -12,5 +12,6 @@ use Exception; * @author Evert Pot (http://evertpot.com/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class MaxInstancesExceededException extends Exception { +class MaxInstancesExceededException extends Exception +{ } diff --git a/vendor/sabre/vobject/lib/Recur/NoInstancesException.php b/vendor/sabre/vobject/lib/Recur/NoInstancesException.php index 8f8bb472b..b55af567d 100644 --- a/vendor/sabre/vobject/lib/Recur/NoInstancesException.php +++ b/vendor/sabre/vobject/lib/Recur/NoInstancesException.php @@ -13,6 +13,6 @@ use Exception; * @author Evert Pot (http://evertpot.com/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class NoInstancesException extends Exception { - +class NoInstancesException extends Exception +{ } diff --git a/vendor/sabre/vobject/lib/Recur/RDateIterator.php b/vendor/sabre/vobject/lib/Recur/RDateIterator.php index f44960e12..013694b95 100644 --- a/vendor/sabre/vobject/lib/Recur/RDateIterator.php +++ b/vendor/sabre/vobject/lib/Recur/RDateIterator.php @@ -19,29 +19,30 @@ use Sabre\VObject\DateTimeParser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RDateIterator implements Iterator { - +class RDateIterator implements Iterator +{ /** * Creates the Iterator. * - * @param string|array $rrule + * @param string|array $rrule * @param DateTimeInterface $start */ - function __construct($rrule, DateTimeInterface $start) { - + public function __construct($rrule, DateTimeInterface $start) + { $this->startDate = $start; $this->parseRDate($rrule); $this->currentDate = clone $this->startDate; - } /* Implementation of the Iterator interface {{{ */ - function current() { + public function current() + { + if (!$this->valid()) { + return; + } - if (!$this->valid()) return; return clone $this->currentDate; - } /** @@ -49,10 +50,9 @@ class RDateIterator implements Iterator { * * @return int */ - function key() { - + public function key() + { return $this->counter; - } /** @@ -61,40 +61,35 @@ class RDateIterator implements Iterator { * * @return bool */ - function valid() { - - return ($this->counter <= count($this->dates)); - + public function valid() + { + return $this->counter <= count($this->dates); } /** * Resets the iterator. - * - * @return void */ - function rewind() { - + public function rewind() + { $this->currentDate = clone $this->startDate; $this->counter = 0; - } /** * Goes on to the next iteration. - * - * @return void */ - function next() { - - $this->counter++; - if (!$this->valid()) return; + public function next() + { + ++$this->counter; + if (!$this->valid()) { + return; + } $this->currentDate = DateTimeParser::parse( $this->dates[$this->counter - 1], $this->startDate->getTimezone() ); - } /* End of Iterator implementation }}} */ @@ -104,10 +99,9 @@ class RDateIterator implements Iterator { * * @return bool */ - function isInfinite() { - + public function isInfinite() + { return false; - } /** @@ -115,15 +109,12 @@ class RDateIterator implements Iterator { * specified date. * * @param DateTimeInterface $dt - * - * @return void */ - function fastForward(DateTimeInterface $dt) { - + public function fastForward(DateTimeInterface $dt) + { while ($this->valid() && $this->currentDate < $dt) { $this->next(); } - } /** @@ -159,24 +150,20 @@ class RDateIterator implements Iterator { * class with all the values. * * @param string|array $rrule - * - * @return void */ - protected function parseRDate($rdate) { - + protected function parseRDate($rdate) + { if (is_string($rdate)) { $rdate = explode(',', $rdate); } $this->dates = $rdate; - } /** - * Array with the RRULE dates + * Array with the RRULE dates. * * @var array */ protected $dates = []; - } diff --git a/vendor/sabre/vobject/lib/Recur/RRuleIterator.php b/vendor/sabre/vobject/lib/Recur/RRuleIterator.php index dbea1155d..554507f19 100644 --- a/vendor/sabre/vobject/lib/Recur/RRuleIterator.php +++ b/vendor/sabre/vobject/lib/Recur/RRuleIterator.php @@ -22,29 +22,30 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RRuleIterator implements Iterator { - +class RRuleIterator implements Iterator +{ /** * Creates the Iterator. * - * @param string|array $rrule + * @param string|array $rrule * @param DateTimeInterface $start */ - function __construct($rrule, DateTimeInterface $start) { - + public function __construct($rrule, DateTimeInterface $start) + { $this->startDate = $start; $this->parseRRule($rrule); $this->currentDate = clone $this->startDate; - } /* Implementation of the Iterator interface {{{ */ - function current() { + public function current() + { + if (!$this->valid()) { + return; + } - if (!$this->valid()) return; return clone $this->currentDate; - } /** @@ -52,10 +53,9 @@ class RRuleIterator implements Iterator { * * @return int */ - function key() { - + public function key() + { return $this->counter; - } /** @@ -65,61 +65,53 @@ class RRuleIterator implements Iterator { * * @return bool */ - function valid() { - + public function valid() + { if (!is_null($this->count)) { return $this->counter < $this->count; } - return is_null($this->until) || $this->currentDate <= $this->until; + return is_null($this->until) || $this->currentDate <= $this->until; } /** * Resets the iterator. - * - * @return void */ - function rewind() { - + public function rewind() + { $this->currentDate = clone $this->startDate; $this->counter = 0; - } /** * Goes on to the next iteration. - * - * @return void */ - function next() { - + public function next() + { // Otherwise, we find the next event in the normal RRULE // sequence. switch ($this->frequency) { - - case 'hourly' : + case 'hourly': $this->nextHourly(); break; - case 'daily' : + case 'daily': $this->nextDaily(); break; - case 'weekly' : + case 'weekly': $this->nextWeekly(); break; - case 'monthly' : + case 'monthly': $this->nextMonthly(); break; - case 'yearly' : + case 'yearly': $this->nextYearly(); break; - } - $this->counter++; - + ++$this->counter; } /* End of Iterator implementation }}} */ @@ -129,10 +121,9 @@ class RRuleIterator implements Iterator { * * @return bool */ - function isInfinite() { - + public function isInfinite() + { return !$this->count && !$this->until; - } /** @@ -140,15 +131,12 @@ class RRuleIterator implements Iterator { * specified date. * * @param DateTimeInterface $dt - * - * @return void */ - function fastForward(DateTimeInterface $dt) { - + public function fastForward(DateTimeInterface $dt) + { while ($this->valid() && $this->currentDate < $dt) { $this->next(); } - } /** @@ -317,24 +305,20 @@ class RRuleIterator implements Iterator { /** * Does the processing for advancing the iterator for hourly frequency. - * - * @return void */ - protected function nextHourly() { - - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' hours'); - + protected function nextHourly() + { + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' hours'); } /** * Does the processing for advancing the iterator for daily frequency. - * - * @return void */ - protected function nextDaily() { - + protected function nextDaily() + { if (!$this->byHour && !$this->byDay) { - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' days'); + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' days'); + return; } @@ -352,16 +336,14 @@ class RRuleIterator implements Iterator { do { if ($this->byHour) { - if ($this->currentDate->format('G') == '23') { + if ('23' == $this->currentDate->format('G')) { // to obey the interval rule - $this->currentDate = $this->currentDate->modify('+' . $this->interval - 1 . ' days'); + $this->currentDate = $this->currentDate->modify('+'.$this->interval - 1 .' days'); } $this->currentDate = $this->currentDate->modify('+1 hours'); - } else { - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' days'); - + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' days'); } // Current month of the year @@ -372,24 +354,21 @@ class RRuleIterator implements Iterator { // Current hour of the day $currentHour = $this->currentDate->format('G'); - } while ( ($this->byDay && !in_array($currentDay, $recurrenceDays)) || ($this->byHour && !in_array($currentHour, $recurrenceHours)) || ($this->byMonth && !in_array($currentMonth, $recurrenceMonths)) ); - } /** * Does the processing for advancing the iterator for weekly frequency. - * - * @return void */ - protected function nextWeekly() { - + protected function nextWeekly() + { if (!$this->byHour && !$this->byDay) { - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' weeks'); + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' weeks'); + return; } @@ -405,7 +384,6 @@ class RRuleIterator implements Iterator { $firstDay = $this->dayMap[$this->weekStart]; do { - if ($this->byHour) { $this->currentDate = $this->currentDate->modify('+1 hours'); } else { @@ -413,19 +391,19 @@ class RRuleIterator implements Iterator { } // Current day of the week - $currentDay = (int)$this->currentDate->format('w'); + $currentDay = (int) $this->currentDate->format('w'); // Current hour of the day - $currentHour = (int)$this->currentDate->format('G'); + $currentHour = (int) $this->currentDate->format('G'); // We need to roll over to the next week - if ($currentDay === $firstDay && (!$this->byHour || $currentHour == '0')) { - $this->currentDate = $this->currentDate->modify('+' . $this->interval - 1 . ' weeks'); + if ($currentDay === $firstDay && (!$this->byHour || '0' == $currentHour)) { + $this->currentDate = $this->currentDate->modify('+'.$this->interval - 1 .' weeks'); // We need to go to the first day of this week, but only if we // are not already on this first day of this week. if ($this->currentDate->format('w') != $firstDay) { - $this->currentDate = $this->currentDate->modify('last ' . $this->dayNames[$this->dayMap[$this->weekStart]]); + $this->currentDate = $this->currentDate->modify('last '.$this->dayNames[$this->dayMap[$this->weekStart]]); } } @@ -435,43 +413,38 @@ class RRuleIterator implements Iterator { /** * Does the processing for advancing the iterator for monthly frequency. - * - * @return void */ - protected function nextMonthly() { - + protected function nextMonthly() + { $currentDayOfMonth = $this->currentDate->format('j'); if (!$this->byMonthDay && !$this->byDay) { - // If the current day is higher than the 28th, rollover can // occur to the next month. We Must skip these invalid // entries. if ($currentDayOfMonth < 29) { - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' months'); + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' months'); } else { $increase = 0; do { - $increase++; + ++$increase; $tempDate = clone $this->currentDate; - $tempDate = $tempDate->modify('+ ' . ($this->interval * $increase) . ' months'); + $tempDate = $tempDate->modify('+ '.($this->interval * $increase).' months'); } while ($tempDate->format('j') != $currentDayOfMonth); $this->currentDate = $tempDate; } + return; } while (true) { - $occurrences = $this->getMonthlyOccurrences(); foreach ($occurrences as $occurrence) { - // The first occurrence thats higher than the current // day of the month wins. if ($occurrence > $currentDayOfMonth) { break 2; } - } // If we made it all the way here, it means there were no @@ -483,42 +456,36 @@ class RRuleIterator implements Iterator { // $this->currentDate->modify('first day of this month'); $this->currentDate = new DateTimeImmutable($this->currentDate->format('Y-m-1 H:i:s'), $this->currentDate->getTimezone()); // end of workaround - $this->currentDate = $this->currentDate->modify('+ ' . $this->interval . ' months'); + $this->currentDate = $this->currentDate->modify('+ '.$this->interval.' months'); // This goes to 0 because we need to start counting at the // beginning. $currentDayOfMonth = 0; - } $this->currentDate = $this->currentDate->setDate( - (int)$this->currentDate->format('Y'), - (int)$this->currentDate->format('n'), - (int)$occurrence + (int) $this->currentDate->format('Y'), + (int) $this->currentDate->format('n'), + (int) $occurrence ); - } /** * Does the processing for advancing the iterator for yearly frequency. - * - * @return void */ - protected function nextYearly() { - + protected function nextYearly() + { $currentMonth = $this->currentDate->format('n'); $currentYear = $this->currentDate->format('Y'); $currentDayOfMonth = $this->currentDate->format('j'); // No sub-rules, so we just advance by year if (empty($this->byMonth)) { - // Unless it was a leap day! - if ($currentMonth == 2 && $currentDayOfMonth == 29) { - + if (2 == $currentMonth && 29 == $currentDayOfMonth) { $counter = 0; do { - $counter++; + ++$counter; // Here we increase the year count by the interval, until // we hit a date that's also in a leap year. // @@ -528,16 +495,15 @@ class RRuleIterator implements Iterator { // 400. (1800, 1900, 2100). So we just rely on the datetime // functions instead. $nextDate = clone $this->currentDate; - $nextDate = $nextDate->modify('+ ' . ($this->interval * $counter) . ' years'); - } while ($nextDate->format('n') != 2); + $nextDate = $nextDate->modify('+ '.($this->interval * $counter).' years'); + } while (2 != $nextDate->format('n')); $this->currentDate = $nextDate; return; - } - if ($this->byWeekNo !== null) { // byWeekNo is an array with values from -53 to -1, or 1 to 53 + if (null !== $this->byWeekNo) { // byWeekNo is an array with values from -53 to -1, or 1 to 53 $dayOffsets = []; if ($this->byDay) { foreach ($this->byDay as $byDay) { @@ -566,6 +532,7 @@ class RRuleIterator implements Iterator { if (count($checkDates) > 0) { $this->currentDate = min($checkDates); + return; } @@ -574,14 +541,14 @@ class RRuleIterator implements Iterator { } } - if ($this->byYearDay !== null) { // byYearDay is an array with values from -366 to -1, or 1 to 366 + if (null !== $this->byYearDay) { // byYearDay is an array with values from -366 to -1, or 1 to 366 $dayOffsets = []; if ($this->byDay) { foreach ($this->byDay as $byDay) { $dayOffsets[] = $this->dayMap[$byDay]; } } else { // default is Monday-Sunday - $dayOffsets = [1,2,3,4,5,6,7]; + $dayOffsets = [1, 2, 3, 4, 5, 6, 7]; } $currentYear = $this->currentDate->format('Y'); @@ -594,9 +561,9 @@ class RRuleIterator implements Iterator { $date = clone $this->currentDate; $date = $date->setDate($currentYear, 1, 1); if ($byYearDay > 0) { - $date = $date->add(new \DateInterval('P' . $byYearDay . 'D')); + $date = $date->add(new \DateInterval('P'.$byYearDay.'D')); } else { - $date = $date->sub(new \DateInterval('P' . abs($byYearDay) . 'D')); + $date = $date->sub(new \DateInterval('P'.abs($byYearDay).'D')); } if ($date > $this->currentDate && in_array($date->format('N'), $dayOffsets)) { @@ -606,6 +573,7 @@ class RRuleIterator implements Iterator { if (count($checkDates) > 0) { $this->currentDate = min($checkDates); + return; } @@ -615,9 +583,9 @@ class RRuleIterator implements Iterator { } // The easiest form - $this->currentDate = $this->currentDate->modify('+' . $this->interval . ' years'); - return; + $this->currentDate = $this->currentDate->modify('+'.$this->interval.' years'); + return; } $currentMonth = $this->currentDate->format('n'); @@ -629,13 +597,10 @@ class RRuleIterator implements Iterator { // If we got a byDay or getMonthDay filter, we must first expand // further. if ($this->byDay || $this->byMonthDay) { - while (true) { - $occurrences = $this->getMonthlyOccurrences(); foreach ($occurrences as $occurrence) { - // The first occurrence that's higher than the current // day of the month wins. // If we advanced to the next month or year, the first @@ -643,7 +608,6 @@ class RRuleIterator implements Iterator { if ($occurrence > $currentDayOfMonth || $advancedToNewMonth) { break 2; } - } // If we made it here, it means we need to advance to @@ -651,8 +615,7 @@ class RRuleIterator implements Iterator { $currentDayOfMonth = 1; $advancedToNewMonth = true; do { - - $currentMonth++; + ++$currentMonth; if ($currentMonth > 12) { $currentYear += $this->interval; $currentMonth = 1; @@ -660,43 +623,38 @@ class RRuleIterator implements Iterator { } while (!in_array($currentMonth, $this->byMonth)); $this->currentDate = $this->currentDate->setDate( - (int)$currentYear, - (int)$currentMonth, - (int)$currentDayOfMonth + (int) $currentYear, + (int) $currentMonth, + (int) $currentDayOfMonth ); - } // If we made it here, it means we got a valid occurrence $this->currentDate = $this->currentDate->setDate( - (int)$currentYear, - (int)$currentMonth, - (int)$occurrence + (int) $currentYear, + (int) $currentMonth, + (int) $occurrence ); - return; + return; } else { - // These are the 'byMonth' rules, if there are no byDay or // byMonthDay sub-rules. do { - - $currentMonth++; + ++$currentMonth; if ($currentMonth > 12) { $currentYear += $this->interval; $currentMonth = 1; } } while (!in_array($currentMonth, $this->byMonth)); $this->currentDate = $this->currentDate->setDate( - (int)$currentYear, - (int)$currentMonth, - (int)$currentDayOfMonth + (int) $currentYear, + (int) $currentMonth, + (int) $currentDayOfMonth ); return; - } - } /* }}} */ @@ -706,32 +664,28 @@ class RRuleIterator implements Iterator { * class with all the values. * * @param string|array $rrule - * - * @return void */ - protected function parseRRule($rrule) { - + protected function parseRRule($rrule) + { if (is_string($rrule)) { $rrule = Property\ICalendar\Recur::stringToArray($rrule); } foreach ($rrule as $key => $value) { - $key = strtoupper($key); switch ($key) { - - case 'FREQ' : + case 'FREQ': $value = strtolower($value); if (!in_array( $value, ['secondly', 'minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly'] )) { - throw new InvalidDataException('Unknown value for FREQ=' . strtoupper($value)); + throw new InvalidDataException('Unknown value for FREQ='.strtoupper($value)); } $this->frequency = $value; break; - case 'UNTIL' : + case 'UNTIL': $this->until = DateTimeParser::parse($value, $this->startDate->getTimezone()); // In some cases events are generated with an UNTIL= @@ -747,86 +701,82 @@ class RRuleIterator implements Iterator { } break; - case 'INTERVAL' : - // No break + case 'INTERVAL': - case 'COUNT' : - $val = (int)$value; + case 'COUNT': + $val = (int) $value; if ($val < 1) { - throw new InvalidDataException(strtoupper($key) . ' in RRULE must be a positive integer!'); + throw new InvalidDataException(strtoupper($key).' in RRULE must be a positive integer!'); } $key = strtolower($key); $this->$key = $val; break; - case 'BYSECOND' : - $this->bySecond = (array)$value; + case 'BYSECOND': + $this->bySecond = (array) $value; break; - case 'BYMINUTE' : - $this->byMinute = (array)$value; + case 'BYMINUTE': + $this->byMinute = (array) $value; break; - case 'BYHOUR' : - $this->byHour = (array)$value; + case 'BYHOUR': + $this->byHour = (array) $value; break; - case 'BYDAY' : - $value = (array)$value; + case 'BYDAY': + $value = (array) $value; foreach ($value as $part) { if (!preg_match('#^ (-|\+)? ([1-5])? (MO|TU|WE|TH|FR|SA|SU) $# xi', $part)) { - throw new InvalidDataException('Invalid part in BYDAY clause: ' . $part); + throw new InvalidDataException('Invalid part in BYDAY clause: '.$part); } } $this->byDay = $value; break; - case 'BYMONTHDAY' : - $this->byMonthDay = (array)$value; + case 'BYMONTHDAY': + $this->byMonthDay = (array) $value; break; - case 'BYYEARDAY' : - $this->byYearDay = (array)$value; + case 'BYYEARDAY': + $this->byYearDay = (array) $value; foreach ($this->byYearDay as $byYearDay) { - if (!is_numeric($byYearDay) || (int)$byYearDay < -366 || (int)$byYearDay == 0 || (int)$byYearDay > 366) { + if (!is_numeric($byYearDay) || (int) $byYearDay < -366 || 0 == (int) $byYearDay || (int) $byYearDay > 366) { throw new InvalidDataException('BYYEARDAY in RRULE must have value(s) from 1 to 366, or -366 to -1!'); } } break; - case 'BYWEEKNO' : - $this->byWeekNo = (array)$value; + case 'BYWEEKNO': + $this->byWeekNo = (array) $value; foreach ($this->byWeekNo as $byWeekNo) { - if (!is_numeric($byWeekNo) || (int)$byWeekNo < -53 || (int)$byWeekNo == 0 || (int)$byWeekNo > 53) { + if (!is_numeric($byWeekNo) || (int) $byWeekNo < -53 || 0 == (int) $byWeekNo || (int) $byWeekNo > 53) { throw new InvalidDataException('BYWEEKNO in RRULE must have value(s) from 1 to 53, or -53 to -1!'); } } break; - case 'BYMONTH' : - $this->byMonth = (array)$value; + case 'BYMONTH': + $this->byMonth = (array) $value; foreach ($this->byMonth as $byMonth) { - if (!is_numeric($byMonth) || (int)$byMonth < 1 || (int)$byMonth > 12) { + if (!is_numeric($byMonth) || (int) $byMonth < 1 || (int) $byMonth > 12) { throw new InvalidDataException('BYMONTH in RRULE must have value(s) betweeen 1 and 12!'); } } break; - case 'BYSETPOS' : - $this->bySetPos = (array)$value; + case 'BYSETPOS': + $this->bySetPos = (array) $value; break; - case 'WKST' : + case 'WKST': $this->weekStart = strtoupper($value); break; default: - throw new InvalidDataException('Not supported: ' . strtoupper($key)); - + throw new InvalidDataException('Not supported: '.strtoupper($key)); } - } - } /** @@ -852,77 +802,75 @@ class RRuleIterator implements Iterator { * * @return array */ - protected function getMonthlyOccurrences() { - + protected function getMonthlyOccurrences() + { $startDate = clone $this->currentDate; $byDayResults = []; // Our strategy is to simply go through the byDays, advance the date to // that point and add it to the results. - if ($this->byDay) foreach ($this->byDay as $day) { - - $dayName = $this->dayNames[$this->dayMap[substr($day, -2)]]; - - - // Dayname will be something like 'wednesday'. Now we need to find - // all wednesdays in this month. - $dayHits = []; - - // workaround for missing 'first day of the month' support in hhvm - $checkDate = new \DateTime($startDate->format('Y-m-1')); - // workaround modify always advancing the date even if the current day is a $dayName in hhvm - if ($checkDate->format('l') !== $dayName) { - $checkDate = $checkDate->modify($dayName); - } + if ($this->byDay) { + foreach ($this->byDay as $day) { + $dayName = $this->dayNames[$this->dayMap[substr($day, -2)]]; + + // Dayname will be something like 'wednesday'. Now we need to find + // all wednesdays in this month. + $dayHits = []; + + // workaround for missing 'first day of the month' support in hhvm + $checkDate = new \DateTime($startDate->format('Y-m-1')); + // workaround modify always advancing the date even if the current day is a $dayName in hhvm + if ($checkDate->format('l') !== $dayName) { + $checkDate = $checkDate->modify($dayName); + } - do { - $dayHits[] = $checkDate->format('j'); - $checkDate = $checkDate->modify('next ' . $dayName); - } while ($checkDate->format('n') === $startDate->format('n')); - - // So now we have 'all wednesdays' for month. It is however - // possible that the user only really wanted the 1st, 2nd or last - // wednesday. - if (strlen($day) > 2) { - $offset = (int)substr($day, 0, -2); - - if ($offset > 0) { - // It is possible that the day does not exist, such as a - // 5th or 6th wednesday of the month. - if (isset($dayHits[$offset - 1])) { - $byDayResults[] = $dayHits[$offset - 1]; + do { + $dayHits[] = $checkDate->format('j'); + $checkDate = $checkDate->modify('next '.$dayName); + } while ($checkDate->format('n') === $startDate->format('n')); + + // So now we have 'all wednesdays' for month. It is however + // possible that the user only really wanted the 1st, 2nd or last + // wednesday. + if (strlen($day) > 2) { + $offset = (int) substr($day, 0, -2); + + if ($offset > 0) { + // It is possible that the day does not exist, such as a + // 5th or 6th wednesday of the month. + if (isset($dayHits[$offset - 1])) { + $byDayResults[] = $dayHits[$offset - 1]; + } + } else { + // if it was negative we count from the end of the array + // might not exist, fx. -5th tuesday + if (isset($dayHits[count($dayHits) + $offset])) { + $byDayResults[] = $dayHits[count($dayHits) + $offset]; + } } } else { - - // if it was negative we count from the end of the array - // might not exist, fx. -5th tuesday - if (isset($dayHits[count($dayHits) + $offset])) { - $byDayResults[] = $dayHits[count($dayHits) + $offset]; - } + // There was no counter (first, second, last wednesdays), so we + // just need to add the all to the list). + $byDayResults = array_merge($byDayResults, $dayHits); } - } else { - // There was no counter (first, second, last wednesdays), so we - // just need to add the all to the list). - $byDayResults = array_merge($byDayResults, $dayHits); - } - } $byMonthDayResults = []; - if ($this->byMonthDay) foreach ($this->byMonthDay as $monthDay) { - - // Removing values that are out of range for this month - if ($monthDay > $startDate->format('t') || + if ($this->byMonthDay) { + foreach ($this->byMonthDay as $monthDay) { + // Removing values that are out of range for this month + if ($monthDay > $startDate->format('t') || $monthDay < 0 - $startDate->format('t')) { continue; - } - if ($monthDay > 0) { - $byMonthDayResults[] = $monthDay; - } else { - // Negative values - $byMonthDayResults[] = $startDate->format('t') + 1 + $monthDay; + } + if ($monthDay > 0) { + $byMonthDayResults[] = $monthDay; + } else { + // Negative values + $byMonthDayResults[] = $startDate->format('t') + 1 + $monthDay; + } } } @@ -947,7 +895,6 @@ class RRuleIterator implements Iterator { $filteredResult = []; foreach ($this->bySetPos as $setPos) { - if ($setPos < 0) { $setPos = count($result) + ($setPos + 1); } @@ -957,8 +904,8 @@ class RRuleIterator implements Iterator { } sort($filteredResult, SORT_NUMERIC); - return $filteredResult; + return $filteredResult; } /** @@ -976,8 +923,8 @@ class RRuleIterator implements Iterator { 'SA' => 6, ]; - protected function getHours() { - + protected function getHours() + { $recurrenceHours = []; foreach ($this->byHour as $byHour) { $recurrenceHours[] = $byHour; @@ -986,23 +933,21 @@ class RRuleIterator implements Iterator { return $recurrenceHours; } - protected function getDays() { - + protected function getDays() + { $recurrenceDays = []; foreach ($this->byDay as $byDay) { - // The day may be preceeded with a positive (+n) or // negative (-n) integer. However, this does not make // sense in 'weekly' so we ignore it here. $recurrenceDays[] = $this->dayMap[substr($byDay, -2)]; - } return $recurrenceDays; } - protected function getMonths() { - + protected function getMonths() + { $recurrenceMonths = []; foreach ($this->byMonth as $byMonth) { $recurrenceMonths[] = $byMonth; diff --git a/vendor/sabre/vobject/lib/Settings.php b/vendor/sabre/vobject/lib/Settings.php index 3f274ba8e..afc586b0c 100644 --- a/vendor/sabre/vobject/lib/Settings.php +++ b/vendor/sabre/vobject/lib/Settings.php @@ -15,8 +15,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Settings { - +class Settings +{ /** * The minimum date we accept for various calculations with dates, such as * recurrences. @@ -25,7 +25,7 @@ class Settings { * use-cases. In particular, it covers birthdates for virtually everyone * alive on earth, which is less than 5 people at the time of writing. */ - static $minDate = '1900-01-01'; + public static $minDate = '1900-01-01'; /** * The maximum date we accept for various calculations with dates, such as @@ -34,7 +34,7 @@ class Settings { * The choice of 2100 is pretty arbitrary, but should cover most * appointments made for many years to come. */ - static $maxDate = '2100-01-01'; + public static $maxDate = '2100-01-01'; /** * The maximum number of recurrences that will be generated. @@ -51,6 +51,5 @@ class Settings { * * Set this value to -1 to disable this control altogether. */ - static $maxRecurrences = 3500; - + public static $maxRecurrences = 3500; } diff --git a/vendor/sabre/vobject/lib/Splitter/ICalendar.php b/vendor/sabre/vobject/lib/Splitter/ICalendar.php index c0007ba01..d42566194 100644 --- a/vendor/sabre/vobject/lib/Splitter/ICalendar.php +++ b/vendor/sabre/vobject/lib/Splitter/ICalendar.php @@ -19,8 +19,8 @@ use Sabre\VObject\Component\VCalendar; * @author Armin Hackmann * @license http://sabre.io/license/ Modified BSD License */ -class ICalendar implements SplitterInterface { - +class ICalendar implements SplitterInterface +{ /** * Timezones. * @@ -38,13 +38,13 @@ class ICalendar implements SplitterInterface { /** * Constructor. * - * The splitter should receive an readable file stream as it's input. + * The splitter should receive an readable file stream as its input. * * @param resource $input - * @param int $options Parser options, see the OPTIONS constants. + * @param int $options parser options, see the OPTIONS constants */ - function __construct($input, $options = 0) { - + public function __construct($input, $options = 0) + { $data = VObject\Reader::read($input, $options); if (!$data instanceof VObject\Component\VCalendar) { @@ -57,16 +57,16 @@ class ICalendar implements SplitterInterface { } // Get all timezones - if ($component->name === 'VTIMEZONE') { - $this->vtimezones[(string)$component->TZID] = $component; + if ('VTIMEZONE' === $component->name) { + $this->vtimezones[(string) $component->TZID] = $component; continue; } // Get component UID for recurring Events search if (!$component->UID) { - $component->UID = sha1(microtime()) . '-vobjectimport'; + $component->UID = sha1(microtime()).'-vobjectimport'; } - $uid = (string)$component->UID; + $uid = (string) $component->UID; // Take care of recurring events if (!array_key_exists($uid, $this->objects)) { @@ -75,7 +75,6 @@ class ICalendar implements SplitterInterface { $this->objects[$uid]->add(clone $component); } - } /** @@ -84,15 +83,14 @@ class ICalendar implements SplitterInterface { * * When the end is reached, null will be returned. * - * @return Sabre\VObject\Component|null + * @return \Sabre\VObject\Component|null */ - function getNext() { - + public function getNext() + { if ($object = array_shift($this->objects)) { - // create our baseobject $object->version = '2.0'; - $object->prodid = '-//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN'; + $object->prodid = '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN'; $object->calscale = 'GREGORIAN'; // add vtimezone information to obj (if we have it) @@ -101,13 +99,8 @@ class ICalendar implements SplitterInterface { } return $object; - } else { - return; - } - } - } diff --git a/vendor/sabre/vobject/lib/Splitter/SplitterInterface.php b/vendor/sabre/vobject/lib/Splitter/SplitterInterface.php index 8f827cc4b..c845ac5fc 100644 --- a/vendor/sabre/vobject/lib/Splitter/SplitterInterface.php +++ b/vendor/sabre/vobject/lib/Splitter/SplitterInterface.php @@ -15,16 +15,16 @@ namespace Sabre\VObject\Splitter; * @author Dominik Tobschall (http://tobschall.de/) * @license http://sabre.io/license/ Modified BSD License */ -interface SplitterInterface { - +interface SplitterInterface +{ /** * Constructor. * - * The splitter should receive an readable file stream as it's input. + * The splitter should receive an readable file stream as its input. * * @param resource $input */ - function __construct($input); + public function __construct($input); /** * Every time getNext() is called, a new object will be parsed, until we @@ -32,8 +32,7 @@ interface SplitterInterface { * * When the end is reached, null will be returned. * - * @return Sabre\VObject\Component|null + * @return \Sabre\VObject\Component|null */ - function getNext(); - + public function getNext(); } diff --git a/vendor/sabre/vobject/lib/Splitter/VCard.php b/vendor/sabre/vobject/lib/Splitter/VCard.php index 0bb82abe9..a20f5c2c1 100644 --- a/vendor/sabre/vobject/lib/Splitter/VCard.php +++ b/vendor/sabre/vobject/lib/Splitter/VCard.php @@ -19,8 +19,8 @@ use Sabre\VObject\Parser\MimeDir; * @author Armin Hackmann * @license http://sabre.io/license/ Modified BSD License */ -class VCard implements SplitterInterface { - +class VCard implements SplitterInterface +{ /** * File handle. * @@ -38,16 +38,15 @@ class VCard implements SplitterInterface { /** * Constructor. * - * The splitter should receive an readable file stream as it's input. + * The splitter should receive an readable file stream as its input. * * @param resource $input - * @param int $options Parser options, see the OPTIONS constants. + * @param int $options parser options, see the OPTIONS constants */ - function __construct($input, $options = 0) { - + public function __construct($input, $options = 0) + { $this->input = $input; $this->parser = new MimeDir($input, $options); - } /** @@ -56,23 +55,20 @@ class VCard implements SplitterInterface { * * When the end is reached, null will be returned. * - * @return Sabre\VObject\Component|null + * @return \Sabre\VObject\Component|null */ - function getNext() { - + public function getNext() + { try { $object = $this->parser->parse(); if (!$object instanceof VObject\Component\VCard) { throw new VObject\ParseException('The supplied input contained non-VCARD data.'); } - } catch (VObject\EofException $e) { return; } return $object; - } - } diff --git a/vendor/sabre/vobject/lib/StringUtil.php b/vendor/sabre/vobject/lib/StringUtil.php index b8615f2ba..2333d6ab9 100644 --- a/vendor/sabre/vobject/lib/StringUtil.php +++ b/vendor/sabre/vobject/lib/StringUtil.php @@ -9,8 +9,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil { - +class StringUtil +{ /** * Returns true or false depending on if a string is valid UTF-8. * @@ -18,15 +18,14 @@ class StringUtil { * * @return bool */ - static function isUTF8($str) { - + public static function isUTF8($str) + { // Control characters if (preg_match('%[\x00-\x08\x0B-\x0C\x0E\x0F]%', $str)) { return false; } - return (bool)preg_match('%%u', $str); - + return (bool) preg_match('%%u', $str); } /** @@ -39,12 +38,12 @@ class StringUtil { * * @return string */ - static function convertToUTF8($str) { - + public static function convertToUTF8($str) + { $encoding = mb_detect_encoding($str, ['UTF-8', 'ISO-8859-1', 'WINDOWS-1252'], true); switch ($encoding) { - case 'ISO-8859-1' : + case 'ISO-8859-1': $newStr = utf8_encode($str); break; /* Unreachable code. Not sure yet how we can improve this @@ -53,14 +52,11 @@ class StringUtil { $newStr = iconv('cp1252', 'UTF-8', $str); break; */ - default : + default: $newStr = $str; - } // Removing any control characters - return (preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr)); - + return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr); } - } diff --git a/vendor/sabre/vobject/lib/TimeZoneUtil.php b/vendor/sabre/vobject/lib/TimeZoneUtil.php index 925183e8d..5b1a775c2 100644 --- a/vendor/sabre/vobject/lib/TimeZoneUtil.php +++ b/vendor/sabre/vobject/lib/TimeZoneUtil.php @@ -12,30 +12,30 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TimeZoneUtil { - - static $map = null; +class TimeZoneUtil +{ + public static $map = null; /** * List of microsoft exchange timezone ids. * * Source: http://msdn.microsoft.com/en-us/library/aa563018(loband).aspx */ - static $microsoftExchangeMap = [ - 0 => 'UTC', + public static $microsoftExchangeMap = [ + 0 => 'UTC', 31 => 'Africa/Casablanca', // Insanely, id #2 is used for both Europe/Lisbon, and Europe/Sarajevo. // I'm not even kidding.. We handle this special case in the // getTimeZone method. - 2 => 'Europe/Lisbon', - 1 => 'Europe/London', - 4 => 'Europe/Berlin', - 6 => 'Europe/Prague', - 3 => 'Europe/Paris', + 2 => 'Europe/Lisbon', + 1 => 'Europe/London', + 4 => 'Europe/Berlin', + 6 => 'Europe/Prague', + 3 => 'Europe/Paris', 69 => 'Africa/Luanda', // This was a best guess - 7 => 'Europe/Athens', - 5 => 'Europe/Bucharest', + 7 => 'Europe/Athens', + 5 => 'Europe/Bucharest', 49 => 'Africa/Cairo', 50 => 'Africa/Harare', 59 => 'Europe/Helsinki', @@ -117,13 +117,13 @@ class TimeZoneUtil { * Alternatively, if $failIfUncertain is set to true, it will throw an * exception if we cannot accurately determine the timezone. * - * @param string $tzid + * @param string $tzid * @param Sabre\VObject\Component $vcalendar * - * @return DateTimeZone + * @return \DateTimeZone */ - static function getTimeZone($tzid, Component $vcalendar = null, $failIfUncertain = false) { - + public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUncertain = false) + { // First we will just see if the tzid is a support timezone identifier. // // The only exception is if the timezone starts with (. This is to @@ -135,8 +135,7 @@ class TimeZoneUtil { // Since PHP 5.5.10, the first bit will be used as the timezone and // this method will return just GMT+01:00. This is wrong, because it // doesn't take DST into account. - if ($tzid[0] !== '(') { - + if ('(' !== $tzid[0]) { // PHP has a bug that logs PHP warnings even it shouldn't: // https://bugs.php.net/bug.php?id=67881 // @@ -155,7 +154,6 @@ class TimeZoneUtil { } } catch (\Exception $e) { } - } self::loadTzMaps(); @@ -178,46 +176,40 @@ class TimeZoneUtil { // Maybe the author was hyper-lazy and just included an offset. We // support it, but we aren't happy about it. if (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) { - // Note that the path in the source will never be taken from PHP 5.5.10 // onwards. PHP 5.5.10 supports the "GMT+0100" style of format, so it // already gets returned early in this function. Once we drop support // for versions under PHP 5.5.10, this bit can be taken out of the // source. // @codeCoverageIgnoreStart - return new \DateTimeZone('Etc/GMT' . $matches[1] . ltrim(substr($matches[2], 0, 2), '0')); + return new \DateTimeZone('Etc/GMT'.$matches[1].ltrim(substr($matches[2], 0, 2), '0')); // @codeCoverageIgnoreEnd } if ($vcalendar) { - // If that didn't work, we will scan VTIMEZONE objects foreach ($vcalendar->select('VTIMEZONE') as $vtimezone) { - - if ((string)$vtimezone->TZID === $tzid) { - + if ((string) $vtimezone->TZID === $tzid) { // Some clients add 'X-LIC-LOCATION' with the olson name. if (isset($vtimezone->{'X-LIC-LOCATION'})) { - - $lic = (string)$vtimezone->{'X-LIC-LOCATION'}; + $lic = (string) $vtimezone->{'X-LIC-LOCATION'}; // Libical generators may specify strings like // "SystemV/EST5EDT". For those we must remove the // SystemV part. - if (substr($lic, 0, 8) === 'SystemV/') { + if ('SystemV/' === substr($lic, 0, 8)) { $lic = substr($lic, 8); } return self::getTimeZone($lic, null, $failIfUncertain); - } // Microsoft may add a magic number, which we also have an // answer for. if (isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { - $cdoId = (int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); + $cdoId = (int) $vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); // 2 can mean both Europe/Lisbon and Europe/Sarajevo. - if ($cdoId === 2 && strpos((string)$vtimezone->TZID, 'Sarajevo') !== false) { + if (2 === $cdoId && false !== strpos((string) $vtimezone->TZID, 'Sarajevo')) { return new \DateTimeZone('Europe/Sarajevo'); } @@ -225,37 +217,34 @@ class TimeZoneUtil { return new \DateTimeZone(self::$microsoftExchangeMap[$cdoId]); } } - } - } - } if ($failIfUncertain) { - throw new \InvalidArgumentException('We were unable to determine the correct PHP timezone for tzid: ' . $tzid); + throw new \InvalidArgumentException('We were unable to determine the correct PHP timezone for tzid: '.$tzid); } // If we got all the way here, we default to UTC. return new \DateTimeZone(date_default_timezone_get()); - } /** * This method will load in all the tz mapping information, if it's not yet * done. */ - static function loadTzMaps() { - - if (!is_null(self::$map)) return; + public static function loadTzMaps() + { + if (!is_null(self::$map)) { + return; + } self::$map = array_merge( - include __DIR__ . '/timezonedata/windowszones.php', - include __DIR__ . '/timezonedata/lotuszones.php', - include __DIR__ . '/timezonedata/exchangezones.php', - include __DIR__ . '/timezonedata/php-workaround.php' + include __DIR__.'/timezonedata/windowszones.php', + include __DIR__.'/timezonedata/lotuszones.php', + include __DIR__.'/timezonedata/exchangezones.php', + include __DIR__.'/timezonedata/php-workaround.php' ); - } /** @@ -269,8 +258,8 @@ class TimeZoneUtil { * * @return array */ - static function getIdentifiersBC() { - return include __DIR__ . '/timezonedata/php-bc.php'; + public static function getIdentifiersBC() + { + return include __DIR__.'/timezonedata/php-bc.php'; } - } diff --git a/vendor/sabre/vobject/lib/UUIDUtil.php b/vendor/sabre/vobject/lib/UUIDUtil.php index 24ebe3cf8..066af624c 100644 --- a/vendor/sabre/vobject/lib/UUIDUtil.php +++ b/vendor/sabre/vobject/lib/UUIDUtil.php @@ -13,8 +13,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UUIDUtil { - +class UUIDUtil +{ /** * Returns a pseudo-random v4 UUID. * @@ -24,10 +24,9 @@ class UUIDUtil { * * @return string */ - static function getUUID() { - + public static function getUUID() + { return sprintf( - '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" @@ -57,13 +56,11 @@ class UUIDUtil { * * @return bool */ - static function validateUUID($uuid) { - - return preg_match( + public static function validateUUID($uuid) + { + return 0 !== preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid - ) !== 0; - + ); } - } diff --git a/vendor/sabre/vobject/lib/VCardConverter.php b/vendor/sabre/vobject/lib/VCardConverter.php index 1f6d016f1..156b83b4e 100644 --- a/vendor/sabre/vobject/lib/VCardConverter.php +++ b/vendor/sabre/vobject/lib/VCardConverter.php @@ -9,8 +9,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VCardConverter { - +class VCardConverter +{ /** * Converts a vCard object to a new version. * @@ -27,10 +27,10 @@ class VCardConverter { * If input and output version are identical, a clone is returned. * * @param Component\VCard $input - * @param int $targetVersion + * @param int $targetVersion */ - function convert(Component\VCard $input, $targetVersion) { - + public function convert(Component\VCard $input, $targetVersion) + { $inputVersion = $input->getDocumentType(); if ($inputVersion === $targetVersion) { return clone $input; @@ -43,7 +43,7 @@ class VCardConverter { throw new \InvalidArgumentException('You can only use vCard 3.0 or 4.0 for the target version'); } - $newVersion = $targetVersion === Document::VCARD40 ? '4.0' : '3.0'; + $newVersion = Document::VCARD40 === $targetVersion ? '4.0' : '3.0'; $output = new Component\VCard([ 'VERSION' => $newVersion, @@ -53,13 +53,10 @@ class VCardConverter { unset($output->UID); foreach ($input->children() as $property) { - $this->convertProperty($input, $output, $property, $targetVersion); - } return $output; - } /** @@ -67,13 +64,11 @@ class VCardConverter { * * @param Component\VCard $input * @param Component\VCard $output - * @param Property $property - * @param int $targetVersion - * - * @return void + * @param Property $property + * @param int $targetVersion */ - protected function convertProperty(Component\VCard $input, Component\VCard $output, Property $property, $targetVersion) { - + protected function convertProperty(Component\VCard $input, Component\VCard $output, Property $property, $targetVersion) + { // Skipping these, those are automatically added. if (in_array($property->name, ['VERSION', 'PRODID'])) { return; @@ -95,15 +90,10 @@ class VCardConverter { $valueType ); - - if ($targetVersion === Document::VCARD30) { - + if (Document::VCARD30 === $targetVersion) { if ($property instanceof Property\Uri && in_array($property->name, ['PHOTO', 'LOGO', 'SOUND'])) { - $newProperty = $this->convertUriToBinary($output, $newProperty); - } elseif ($property instanceof Property\VCard\DateAndOrTime) { - // In vCard 4, the birth year may be optional. This is not the // case for vCard 3. Apple has a workaround for this that // allows applications that support Apple's extension still @@ -113,12 +103,12 @@ class VCardConverter { // uses. $parts = DateTimeParser::parseVCardDateTime($property->getValue()); if (is_null($parts['year'])) { - $newValue = '1604-' . $parts['month'] . '-' . $parts['date']; + $newValue = '1604-'.$parts['month'].'-'.$parts['date']; $newProperty->setValue($newValue); $newProperty['X-APPLE-OMIT-YEAR'] = '1604'; } - if ($newProperty->name == 'ANNIVERSARY') { + if ('ANNIVERSARY' == $newProperty->name) { // Microsoft non-standard anniversary $newProperty->name = 'X-ANNIVERSARY'; @@ -127,74 +117,64 @@ class VCardConverter { // group, so we first need to find a groupname that doesn't // exist yet. $x = 1; - while ($output->select('ITEM' . $x . '.')) { - $x++; + while ($output->select('ITEM'.$x.'.')) { + ++$x; } - $output->add('ITEM' . $x . '.X-ABDATE', $newProperty->getValue(), ['VALUE' => 'DATE-AND-OR-TIME']); - $output->add('ITEM' . $x . '.X-ABLABEL', '_$!<Anniversary>!$_'); + $output->add('ITEM'.$x.'.X-ABDATE', $newProperty->getValue(), ['VALUE' => 'DATE-AND-OR-TIME']); + $output->add('ITEM'.$x.'.X-ABLABEL', '_$!<Anniversary>!$_'); } - - } elseif ($property->name === 'KIND') { - + } elseif ('KIND' === $property->name) { switch (strtolower($property->getValue())) { - case 'org' : + case 'org': // vCard 3.0 does not have an equivalent to KIND:ORG, // but apple has an extension that means the same // thing. $newProperty = $output->createProperty('X-ABSHOWAS', 'COMPANY'); break; - case 'individual' : + case 'individual': // Individual is implicit, so we skip it. return; - case 'group' : + case 'group': // OS X addressbook property $newProperty = $output->createProperty('X-ADDRESSBOOKSERVER-KIND', 'GROUP'); break; } - - } - - } elseif ($targetVersion === Document::VCARD40) { - + } elseif (Document::VCARD40 === $targetVersion) { // These properties were removed in vCard 4.0 if (in_array($property->name, ['NAME', 'MAILER', 'LABEL', 'CLASS'])) { return; } if ($property instanceof Property\Binary) { - $newProperty = $this->convertBinaryToUri($output, $newProperty, $parameters); - } elseif ($property instanceof Property\VCard\DateAndOrTime && isset($parameters['X-APPLE-OMIT-YEAR'])) { - // If a property such as BDAY contained 'X-APPLE-OMIT-YEAR', // then we're stripping the year from the vcard 4 value. $parts = DateTimeParser::parseVCardDateTime($property->getValue()); if ($parts['year'] === $property['X-APPLE-OMIT-YEAR']->getValue()) { - $newValue = '--' . $parts['month'] . '-' . $parts['date']; + $newValue = '--'.$parts['month'].'-'.$parts['date']; $newProperty->setValue($newValue); } // Regardless if the year matched or not, we do need to strip // X-APPLE-OMIT-YEAR. unset($parameters['X-APPLE-OMIT-YEAR']); - } switch ($property->name) { - case 'X-ABSHOWAS' : - if (strtoupper($property->getValue()) === 'COMPANY') { + case 'X-ABSHOWAS': + if ('COMPANY' === strtoupper($property->getValue())) { $newProperty = $output->createProperty('KIND', 'ORG'); } break; - case 'X-ADDRESSBOOKSERVER-KIND' : - if (strtoupper($property->getValue()) === 'GROUP') { + case 'X-ADDRESSBOOKSERVER-KIND': + if ('GROUP' === strtoupper($property->getValue())) { $newProperty = $output->createProperty('KIND', 'GROUP'); } break; - case 'X-ANNIVERSARY' : + case 'X-ANNIVERSARY': $newProperty->name = 'ANNIVERSARY'; // If we already have an anniversary property with the same // value, ignore. @@ -204,15 +184,15 @@ class VCardConverter { } } break; - case 'X-ABDATE' : + case 'X-ABDATE': // Find out what the label was, if it exists. if (!$property->group) { break; } - $label = $input->{$property->group . '.X-ABLABEL'}; + $label = $input->{$property->group.'.X-ABLABEL'}; // We only support converting anniversaries. - if (!$label || $label->getValue() !== '_$!<Anniversary>!$_') { + if (!$label || '_$!<Anniversary>!$_' !== $label->getValue()) { break; } @@ -226,22 +206,20 @@ class VCardConverter { $newProperty->name = 'ANNIVERSARY'; break; // Apple's per-property label system. - case 'X-ABLABEL' : - if ($newProperty->getValue() === '_$!<Anniversary>!$_') { + case 'X-ABLABEL': + if ('_$!<Anniversary>!$_' === $newProperty->getValue()) { // We can safely remove these, as they are converted to // ANNIVERSARY properties. return; } break; - } - } // set property group $newProperty->group = $property->group; - if ($targetVersion === Document::VCARD40) { + if (Document::VCARD40 === $targetVersion) { $this->convertParameters40($newProperty, $parameters); } else { $this->convertParameters30($newProperty, $parameters); @@ -257,8 +235,6 @@ class VCardConverter { } $output->add($newProperty); - - } /** @@ -267,14 +243,14 @@ class VCardConverter { * vCard 4.0 no longer supports BINARY properties. * * @param Component\VCard $output - * @param Property\Uri $property The input property. - * @param $parameters List of parameters that will eventually be added to - * the new property. + * @param Property\Uri $property the input property + * @param $parameters list of parameters that will eventually be added to + * the new property * * @return Property\Uri */ - protected function convertBinaryToUri(Component\VCard $output, Property\Binary $newProperty, array &$parameters) { - + protected function convertBinaryToUri(Component\VCard $output, Property\Binary $newProperty, array &$parameters) + { $value = $newProperty->getValue(); $newProperty = $output->createProperty( $newProperty->name, @@ -287,14 +263,13 @@ class VCardConverter { // See if we can find a better mimetype. if (isset($parameters['TYPE'])) { - $newTypes = []; foreach ($parameters['TYPE']->getParts() as $typePart) { if (in_array( strtoupper($typePart), ['JPEG', 'PNG', 'GIF'] )) { - $mimeType = 'image/' . strtolower($typePart); + $mimeType = 'image/'.strtolower($typePart); } else { $newTypes[] = $typePart; } @@ -307,12 +282,11 @@ class VCardConverter { } else { unset($parameters['TYPE']); } - } - $newProperty->setValue('data:' . $mimeType . ';base64,' . base64_encode($value)); - return $newProperty; + $newProperty->setValue('data:'.$mimeType.';base64,'.base64_encode($value)); + return $newProperty; } /** @@ -323,16 +297,16 @@ class VCardConverter { * possible, to improve compatibility. * * @param Component\VCard $output - * @param Property\Uri $property The input property. + * @param Property\Uri $property the input property * * @return Property\Binary|null */ - protected function convertUriToBinary(Component\VCard $output, Property\Uri $newProperty) { - + protected function convertUriToBinary(Component\VCard $output, Property\Uri $newProperty) + { $value = $newProperty->getValue(); // Only converting data: uris - if (substr($value, 0, 5) !== 'data:') { + if ('data:' !== substr($value, 0, 5)) { return $newProperty; } @@ -354,92 +328,79 @@ class VCardConverter { $newProperty['ENCODING'] = 'b'; switch ($mimeType) { - - case 'image/jpeg' : + case 'image/jpeg': $newProperty['TYPE'] = 'JPEG'; break; - case 'image/png' : + case 'image/png': $newProperty['TYPE'] = 'PNG'; break; - case 'image/gif' : + case 'image/gif': $newProperty['TYPE'] = 'GIF'; break; - } - return $newProperty; - } /** * Adds parameters to a new property for vCard 4.0. * * @param Property $newProperty - * @param array $parameters - * - * @return void + * @param array $parameters */ - protected function convertParameters40(Property $newProperty, array $parameters) { - + protected function convertParameters40(Property $newProperty, array $parameters) + { // Adding all parameters. foreach ($parameters as $param) { - // vCard 2.1 allowed parameters with no name - if ($param->noName) $param->noName = false; + if ($param->noName) { + $param->noName = false; + } switch ($param->name) { - // We need to see if there's any TYPE=PREF, because in vCard 4 // that's now PREF=1. - case 'TYPE' : + case 'TYPE': foreach ($param->getParts() as $paramPart) { - - if (strtoupper($paramPart) === 'PREF') { + if ('PREF' === strtoupper($paramPart)) { $newProperty->add('PREF', '1'); } else { $newProperty->add($param->name, $paramPart); } - } break; // These no longer exist in vCard 4 - case 'ENCODING' : - case 'CHARSET' : + case 'ENCODING': + case 'CHARSET': break; - default : + default: $newProperty->add($param->name, $param->getParts()); break; - } - } - } /** * Adds parameters to a new property for vCard 3.0. * * @param Property $newProperty - * @param array $parameters - * - * @return void + * @param array $parameters */ - protected function convertParameters30(Property $newProperty, array $parameters) { - + protected function convertParameters30(Property $newProperty, array $parameters) + { // Adding all parameters. foreach ($parameters as $param) { - // vCard 2.1 allowed parameters with no name - if ($param->noName) $param->noName = false; + if ($param->noName) { + $param->noName = false; + } switch ($param->name) { - - case 'ENCODING' : + case 'ENCODING': // This value only existed in vCard 2.1, and should be // removed for anything else. - if (strtoupper($param->getValue()) !== 'QUOTED-PRINTABLE') { + if ('QUOTED-PRINTABLE' !== strtoupper($param->getValue())) { $newProperty->add($param->name, $param->getParts()); } break; @@ -449,19 +410,16 @@ class VCardConverter { * * Any other PREF numbers we'll drop. */ - case 'PREF' : - if ($param->getValue() == '1') { + case 'PREF': + if ('1' == $param->getValue()) { $newProperty->add('TYPE', 'PREF'); } break; - default : + default: $newProperty->add($param->name, $param->getParts()); break; - } - } - } } diff --git a/vendor/sabre/vobject/lib/Version.php b/vendor/sabre/vobject/lib/Version.php index 074b06c4b..257e66a79 100644 --- a/vendor/sabre/vobject/lib/Version.php +++ b/vendor/sabre/vobject/lib/Version.php @@ -9,11 +9,10 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Version { - +class Version +{ /** * Full version number. */ - const VERSION = '4.1.6'; - + const VERSION = '4.2.0'; } diff --git a/vendor/sabre/vobject/lib/Writer.php b/vendor/sabre/vobject/lib/Writer.php index f8a58758d..c70a6ae4d 100644 --- a/vendor/sabre/vobject/lib/Writer.php +++ b/vendor/sabre/vobject/lib/Writer.php @@ -14,8 +14,8 @@ use Sabre\Xml; * @author Ivan Enderlin * @license http://sabre.io/license/ Modified BSD License */ -class Writer { - +class Writer +{ /** * Serializes a vCard or iCalendar object. * @@ -23,24 +23,22 @@ class Writer { * * @return string */ - static function write(Component $component) { - + public static function write(Component $component) + { return $component->serialize(); - } /** * Serializes a jCal or jCard object. * * @param Component $component - * @param int $options + * @param int $options * * @return string */ - static function writeJson(Component $component, $options = 0) { - + public static function writeJson(Component $component, $options = 0) + { return json_encode($component, $options); - } /** @@ -50,8 +48,8 @@ class Writer { * * @return string */ - static function writeXml(Component $component) { - + public static function writeXml(Component $component) + { $writer = new Xml\Writer(); $writer->openMemory(); $writer->setIndent(true); @@ -59,15 +57,11 @@ class Writer { $writer->startDocument('1.0', 'utf-8'); if ($component instanceof Component\VCalendar) { - $writer->startElement('icalendar'); - $writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE); - + $writer->writeAttribute('xmlns', Parser\XML::XCAL_NAMESPACE); } else { - $writer->startElement('vcards'); - $writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE); - + $writer->writeAttribute('xmlns', Parser\XML::XCARD_NAMESPACE); } $component->xmlSerialize($writer); @@ -75,7 +69,5 @@ class Writer { $writer->endElement(); return $writer->outputMemory(); - } - } diff --git a/vendor/sabre/vobject/lib/timezonedata/exchangezones.php b/vendor/sabre/vobject/lib/timezonedata/exchangezones.php index edba5b473..89bddc27c 100644 --- a/vendor/sabre/vobject/lib/timezonedata/exchangezones.php +++ b/vendor/sabre/vobject/lib/timezonedata/exchangezones.php @@ -12,83 +12,83 @@ * @license http://sabre.io/license/ Modified BSD License */ return [ - 'Universal Coordinated Time' => 'UTC', - 'Casablanca, Monrovia' => 'Africa/Casablanca', - 'Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' => 'Europe/Lisbon', - 'Greenwich Mean Time; Dublin, Edinburgh, London' => 'Europe/London', - 'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna' => 'Europe/Berlin', - 'Belgrade, Pozsony, Budapest, Ljubljana, Prague' => 'Europe/Prague', - 'Brussels, Copenhagen, Madrid, Paris' => 'Europe/Paris', - 'Paris, Madrid, Brussels, Copenhagen' => 'Europe/Paris', - 'Prague, Central Europe' => 'Europe/Prague', - 'Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb' => 'Europe/Sarajevo', - 'West Central Africa' => 'Africa/Luanda', // This was a best guess - 'Athens, Istanbul, Minsk' => 'Europe/Athens', - 'Bucharest' => 'Europe/Bucharest', - 'Cairo' => 'Africa/Cairo', - 'Harare, Pretoria' => 'Africa/Harare', - 'Helsinki, Riga, Tallinn' => 'Europe/Helsinki', - 'Israel, Jerusalem Standard Time' => 'Asia/Jerusalem', - 'Baghdad' => 'Asia/Baghdad', - 'Arab, Kuwait, Riyadh' => 'Asia/Kuwait', - 'Moscow, St. Petersburg, Volgograd' => 'Europe/Moscow', - 'East Africa, Nairobi' => 'Africa/Nairobi', - 'Tehran' => 'Asia/Tehran', - 'Abu Dhabi, Muscat' => 'Asia/Muscat', // Best guess - 'Baku, Tbilisi, Yerevan' => 'Asia/Baku', - 'Kabul' => 'Asia/Kabul', - 'Ekaterinburg' => 'Asia/Yekaterinburg', - 'Islamabad, Karachi, Tashkent' => 'Asia/Karachi', + 'Universal Coordinated Time' => 'UTC', + 'Casablanca, Monrovia' => 'Africa/Casablanca', + 'Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' => 'Europe/Lisbon', + 'Greenwich Mean Time; Dublin, Edinburgh, London' => 'Europe/London', + 'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna' => 'Europe/Berlin', + 'Belgrade, Pozsony, Budapest, Ljubljana, Prague' => 'Europe/Prague', + 'Brussels, Copenhagen, Madrid, Paris' => 'Europe/Paris', + 'Paris, Madrid, Brussels, Copenhagen' => 'Europe/Paris', + 'Prague, Central Europe' => 'Europe/Prague', + 'Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb' => 'Europe/Sarajevo', + 'West Central Africa' => 'Africa/Luanda', // This was a best guess + 'Athens, Istanbul, Minsk' => 'Europe/Athens', + 'Bucharest' => 'Europe/Bucharest', + 'Cairo' => 'Africa/Cairo', + 'Harare, Pretoria' => 'Africa/Harare', + 'Helsinki, Riga, Tallinn' => 'Europe/Helsinki', + 'Israel, Jerusalem Standard Time' => 'Asia/Jerusalem', + 'Baghdad' => 'Asia/Baghdad', + 'Arab, Kuwait, Riyadh' => 'Asia/Kuwait', + 'Moscow, St. Petersburg, Volgograd' => 'Europe/Moscow', + 'East Africa, Nairobi' => 'Africa/Nairobi', + 'Tehran' => 'Asia/Tehran', + 'Abu Dhabi, Muscat' => 'Asia/Muscat', // Best guess + 'Baku, Tbilisi, Yerevan' => 'Asia/Baku', + 'Kabul' => 'Asia/Kabul', + 'Ekaterinburg' => 'Asia/Yekaterinburg', + 'Islamabad, Karachi, Tashkent' => 'Asia/Karachi', 'Kolkata, Chennai, Mumbai, New Delhi, India Standard Time' => 'Asia/Calcutta', - 'Kathmandu, Nepal' => 'Asia/Kathmandu', - 'Almaty, Novosibirsk, North Central Asia' => 'Asia/Almaty', - 'Astana, Dhaka' => 'Asia/Dhaka', - 'Sri Jayawardenepura, Sri Lanka' => 'Asia/Colombo', - 'Rangoon' => 'Asia/Rangoon', - 'Bangkok, Hanoi, Jakarta' => 'Asia/Bangkok', - 'Krasnoyarsk' => 'Asia/Krasnoyarsk', - 'Beijing, Chongqing, Hong Kong SAR, Urumqi' => 'Asia/Shanghai', - 'Irkutsk, Ulaan Bataar' => 'Asia/Irkutsk', - 'Kuala Lumpur, Singapore' => 'Asia/Singapore', - 'Perth, Western Australia' => 'Australia/Perth', - 'Taipei' => 'Asia/Taipei', - 'Osaka, Sapporo, Tokyo' => 'Asia/Tokyo', - 'Seoul, Korea Standard time' => 'Asia/Seoul', - 'Yakutsk' => 'Asia/Yakutsk', - 'Adelaide, Central Australia' => 'Australia/Adelaide', - 'Darwin' => 'Australia/Darwin', - 'Brisbane, East Australia' => 'Australia/Brisbane', - 'Canberra, Melbourne, Sydney, Hobart (year 2000 only)' => 'Australia/Sydney', - 'Guam, Port Moresby' => 'Pacific/Guam', - 'Hobart, Tasmania' => 'Australia/Hobart', - 'Vladivostok' => 'Asia/Vladivostok', - 'Magadan, Solomon Is., New Caledonia' => 'Asia/Magadan', - 'Auckland, Wellington' => 'Pacific/Auckland', - 'Fiji Islands, Kamchatka, Marshall Is.' => 'Pacific/Fiji', - 'Nuku\'alofa, Tonga' => 'Pacific/Tongatapu', - 'Azores' => 'Atlantic/Azores', - 'Cape Verde Is.' => 'Atlantic/Cape_Verde', - 'Mid-Atlantic' => 'America/Noronha', - 'Brasilia' => 'America/Sao_Paulo', // Best guess - 'Buenos Aires' => 'America/Argentina/Buenos_Aires', - 'Greenland' => 'America/Godthab', - 'Newfoundland' => 'America/St_Johns', - 'Atlantic Time (Canada)' => 'America/Halifax', - 'Caracas, La Paz' => 'America/Caracas', - 'Santiago' => 'America/Santiago', - 'Bogota, Lima, Quito' => 'America/Bogota', - 'Eastern Time (US & Canada)' => 'America/New_York', - 'Indiana (East)' => 'America/Indiana/Indianapolis', - 'Central America' => 'America/Guatemala', - 'Central Time (US & Canada)' => 'America/Chicago', - 'Mexico City, Tegucigalpa' => 'America/Mexico_City', - 'Saskatchewan' => 'America/Edmonton', - 'Arizona' => 'America/Phoenix', - 'Mountain Time (US & Canada)' => 'America/Denver', // Best guess - 'Pacific Time (US & Canada)' => 'America/Los_Angeles', // Best guess - 'Pacific Time (US & Canada); Tijuana' => 'America/Los_Angeles', // Best guess - 'Alaska' => 'America/Anchorage', - 'Hawaii' => 'Pacific/Honolulu', - 'Midway Island, Samoa' => 'Pacific/Midway', - 'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein', + 'Kathmandu, Nepal' => 'Asia/Kathmandu', + 'Almaty, Novosibirsk, North Central Asia' => 'Asia/Almaty', + 'Astana, Dhaka' => 'Asia/Dhaka', + 'Sri Jayawardenepura, Sri Lanka' => 'Asia/Colombo', + 'Rangoon' => 'Asia/Rangoon', + 'Bangkok, Hanoi, Jakarta' => 'Asia/Bangkok', + 'Krasnoyarsk' => 'Asia/Krasnoyarsk', + 'Beijing, Chongqing, Hong Kong SAR, Urumqi' => 'Asia/Shanghai', + 'Irkutsk, Ulaan Bataar' => 'Asia/Irkutsk', + 'Kuala Lumpur, Singapore' => 'Asia/Singapore', + 'Perth, Western Australia' => 'Australia/Perth', + 'Taipei' => 'Asia/Taipei', + 'Osaka, Sapporo, Tokyo' => 'Asia/Tokyo', + 'Seoul, Korea Standard time' => 'Asia/Seoul', + 'Yakutsk' => 'Asia/Yakutsk', + 'Adelaide, Central Australia' => 'Australia/Adelaide', + 'Darwin' => 'Australia/Darwin', + 'Brisbane, East Australia' => 'Australia/Brisbane', + 'Canberra, Melbourne, Sydney, Hobart (year 2000 only)' => 'Australia/Sydney', + 'Guam, Port Moresby' => 'Pacific/Guam', + 'Hobart, Tasmania' => 'Australia/Hobart', + 'Vladivostok' => 'Asia/Vladivostok', + 'Magadan, Solomon Is., New Caledonia' => 'Asia/Magadan', + 'Auckland, Wellington' => 'Pacific/Auckland', + 'Fiji Islands, Kamchatka, Marshall Is.' => 'Pacific/Fiji', + 'Nuku\'alofa, Tonga' => 'Pacific/Tongatapu', + 'Azores' => 'Atlantic/Azores', + 'Cape Verde Is.' => 'Atlantic/Cape_Verde', + 'Mid-Atlantic' => 'America/Noronha', + 'Brasilia' => 'America/Sao_Paulo', // Best guess + 'Buenos Aires' => 'America/Argentina/Buenos_Aires', + 'Greenland' => 'America/Godthab', + 'Newfoundland' => 'America/St_Johns', + 'Atlantic Time (Canada)' => 'America/Halifax', + 'Caracas, La Paz' => 'America/Caracas', + 'Santiago' => 'America/Santiago', + 'Bogota, Lima, Quito' => 'America/Bogota', + 'Eastern Time (US & Canada)' => 'America/New_York', + 'Indiana (East)' => 'America/Indiana/Indianapolis', + 'Central America' => 'America/Guatemala', + 'Central Time (US & Canada)' => 'America/Chicago', + 'Mexico City, Tegucigalpa' => 'America/Mexico_City', + 'Saskatchewan' => 'America/Edmonton', + 'Arizona' => 'America/Phoenix', + 'Mountain Time (US & Canada)' => 'America/Denver', // Best guess + 'Pacific Time (US & Canada)' => 'America/Los_Angeles', // Best guess + 'Pacific Time (US & Canada); Tijuana' => 'America/Los_Angeles', // Best guess + 'Alaska' => 'America/Anchorage', + 'Hawaii' => 'Pacific/Honolulu', + 'Midway Island, Samoa' => 'Pacific/Midway', + 'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein', ]; diff --git a/vendor/sabre/vobject/lib/timezonedata/lotuszones.php b/vendor/sabre/vobject/lib/timezonedata/lotuszones.php index 79d555a92..4b50808f9 100644 --- a/vendor/sabre/vobject/lib/timezonedata/lotuszones.php +++ b/vendor/sabre/vobject/lib/timezonedata/lotuszones.php @@ -8,94 +8,94 @@ * @license http://sabre.io/license/ Modified BSD License */ return [ - 'Dateline' => 'Etc/GMT-12', - 'Samoa' => 'Pacific/Apia', - 'Hawaiian' => 'Pacific/Honolulu', - 'Alaskan' => 'America/Anchorage', - 'Pacific' => 'America/Los_Angeles', - 'Pacific Standard Time' => 'America/Los_Angeles', + 'Dateline' => 'Etc/GMT-12', + 'Samoa' => 'Pacific/Apia', + 'Hawaiian' => 'Pacific/Honolulu', + 'Alaskan' => 'America/Anchorage', + 'Pacific' => 'America/Los_Angeles', + 'Pacific Standard Time' => 'America/Los_Angeles', 'Mexico Standard Time 2' => 'America/Chihuahua', - 'Mountain' => 'America/Denver', + 'Mountain' => 'America/Denver', // 'Mountain Standard Time' => 'America/Chihuahua', // conflict with windows timezones. - 'US Mountain' => 'America/Phoenix', - 'Canada Central' => 'America/Edmonton', + 'US Mountain' => 'America/Phoenix', + 'Canada Central' => 'America/Edmonton', 'Central America' => 'America/Guatemala', - 'Central' => 'America/Chicago', + 'Central' => 'America/Chicago', // 'Central Standard Time' => 'America/Mexico_City', // conflict with windows timezones. - 'Mexico' => 'America/Mexico_City', - 'Eastern' => 'America/New_York', - 'SA Pacific' => 'America/Bogota', - 'US Eastern' => 'America/Indiana/Indianapolis', - 'Venezuela' => 'America/Caracas', - 'Atlantic' => 'America/Halifax', + 'Mexico' => 'America/Mexico_City', + 'Eastern' => 'America/New_York', + 'SA Pacific' => 'America/Bogota', + 'US Eastern' => 'America/Indiana/Indianapolis', + 'Venezuela' => 'America/Caracas', + 'Atlantic' => 'America/Halifax', 'Central Brazilian' => 'America/Manaus', - 'Pacific SA' => 'America/Santiago', - 'SA Western' => 'America/La_Paz', - 'Newfoundland' => 'America/St_Johns', - 'Argentina' => 'America/Argentina/Buenos_Aires', - 'E. South America' => 'America/Belem', - 'Greenland' => 'America/Godthab', - 'Montevideo' => 'America/Montevideo', - 'SA Eastern' => 'America/Belem', + 'Pacific SA' => 'America/Santiago', + 'SA Western' => 'America/La_Paz', + 'Newfoundland' => 'America/St_Johns', + 'Argentina' => 'America/Argentina/Buenos_Aires', + 'E. South America' => 'America/Belem', + 'Greenland' => 'America/Godthab', + 'Montevideo' => 'America/Montevideo', + 'SA Eastern' => 'America/Belem', // 'Mid-Atlantic' => 'Etc/GMT-2', // conflict with windows timezones. - 'Azores' => 'Atlantic/Azores', - 'Cape Verde' => 'Atlantic/Cape_Verde', - 'Greenwich' => 'Atlantic/Reykjavik', // No I'm serious.. Greenwich is not GMT. - 'Morocco' => 'Africa/Casablanca', - 'Central Europe' => 'Europe/Prague', - 'Central European' => 'Europe/Sarajevo', - 'Romance' => 'Europe/Paris', + 'Azores' => 'Atlantic/Azores', + 'Cape Verde' => 'Atlantic/Cape_Verde', + 'Greenwich' => 'Atlantic/Reykjavik', // No I'm serious.. Greenwich is not GMT. + 'Morocco' => 'Africa/Casablanca', + 'Central Europe' => 'Europe/Prague', + 'Central European' => 'Europe/Sarajevo', + 'Romance' => 'Europe/Paris', 'W. Central Africa' => 'Africa/Lagos', // Best guess - 'W. Europe' => 'Europe/Amsterdam', - 'E. Europe' => 'Europe/Minsk', - 'Egypt' => 'Africa/Cairo', - 'FLE' => 'Europe/Helsinki', - 'GTB' => 'Europe/Athens', - 'Israel' => 'Asia/Jerusalem', - 'Jordan' => 'Asia/Amman', - 'Middle East' => 'Asia/Beirut', - 'Namibia' => 'Africa/Windhoek', - 'South Africa' => 'Africa/Harare', - 'Arab' => 'Asia/Kuwait', - 'Arabic' => 'Asia/Baghdad', - 'E. Africa' => 'Africa/Nairobi', - 'Georgian' => 'Asia/Tbilisi', - 'Russian' => 'Europe/Moscow', - 'Iran' => 'Asia/Tehran', - 'Arabian' => 'Asia/Muscat', - 'Armenian' => 'Asia/Yerevan', - 'Azerbijan' => 'Asia/Baku', - 'Caucasus' => 'Asia/Yerevan', - 'Mauritius' => 'Indian/Mauritius', - 'Afghanistan' => 'Asia/Kabul', - 'Ekaterinburg' => 'Asia/Yekaterinburg', - 'Pakistan' => 'Asia/Karachi', - 'West Asia' => 'Asia/Tashkent', - 'India' => 'Asia/Calcutta', - 'Sri Lanka' => 'Asia/Colombo', - 'Nepal' => 'Asia/Kathmandu', - 'Central Asia' => 'Asia/Dhaka', - 'N. Central Asia' => 'Asia/Almaty', - 'Myanmar' => 'Asia/Rangoon', - 'North Asia' => 'Asia/Krasnoyarsk', - 'SE Asia' => 'Asia/Bangkok', - 'China' => 'Asia/Shanghai', - 'North Asia East' => 'Asia/Irkutsk', - 'Singapore' => 'Asia/Singapore', - 'Taipei' => 'Asia/Taipei', - 'W. Australia' => 'Australia/Perth', - 'Korea' => 'Asia/Seoul', - 'Tokyo' => 'Asia/Tokyo', - 'Yakutsk' => 'Asia/Yakutsk', - 'AUS Central' => 'Australia/Darwin', - 'Cen. Australia' => 'Australia/Adelaide', - 'AUS Eastern' => 'Australia/Sydney', - 'E. Australia' => 'Australia/Brisbane', - 'Tasmania' => 'Australia/Hobart', - 'Vladivostok' => 'Asia/Vladivostok', - 'West Pacific' => 'Pacific/Guam', - 'Central Pacific' => 'Asia/Magadan', - 'Fiji' => 'Pacific/Fiji', - 'New Zealand' => 'Pacific/Auckland', - 'Tonga' => 'Pacific/Tongatapu', + 'W. Europe' => 'Europe/Amsterdam', + 'E. Europe' => 'Europe/Minsk', + 'Egypt' => 'Africa/Cairo', + 'FLE' => 'Europe/Helsinki', + 'GTB' => 'Europe/Athens', + 'Israel' => 'Asia/Jerusalem', + 'Jordan' => 'Asia/Amman', + 'Middle East' => 'Asia/Beirut', + 'Namibia' => 'Africa/Windhoek', + 'South Africa' => 'Africa/Harare', + 'Arab' => 'Asia/Kuwait', + 'Arabic' => 'Asia/Baghdad', + 'E. Africa' => 'Africa/Nairobi', + 'Georgian' => 'Asia/Tbilisi', + 'Russian' => 'Europe/Moscow', + 'Iran' => 'Asia/Tehran', + 'Arabian' => 'Asia/Muscat', + 'Armenian' => 'Asia/Yerevan', + 'Azerbijan' => 'Asia/Baku', + 'Caucasus' => 'Asia/Yerevan', + 'Mauritius' => 'Indian/Mauritius', + 'Afghanistan' => 'Asia/Kabul', + 'Ekaterinburg' => 'Asia/Yekaterinburg', + 'Pakistan' => 'Asia/Karachi', + 'West Asia' => 'Asia/Tashkent', + 'India' => 'Asia/Calcutta', + 'Sri Lanka' => 'Asia/Colombo', + 'Nepal' => 'Asia/Kathmandu', + 'Central Asia' => 'Asia/Dhaka', + 'N. Central Asia' => 'Asia/Almaty', + 'Myanmar' => 'Asia/Rangoon', + 'North Asia' => 'Asia/Krasnoyarsk', + 'SE Asia' => 'Asia/Bangkok', + 'China' => 'Asia/Shanghai', + 'North Asia East' => 'Asia/Irkutsk', + 'Singapore' => 'Asia/Singapore', + 'Taipei' => 'Asia/Taipei', + 'W. Australia' => 'Australia/Perth', + 'Korea' => 'Asia/Seoul', + 'Tokyo' => 'Asia/Tokyo', + 'Yakutsk' => 'Asia/Yakutsk', + 'AUS Central' => 'Australia/Darwin', + 'Cen. Australia' => 'Australia/Adelaide', + 'AUS Eastern' => 'Australia/Sydney', + 'E. Australia' => 'Australia/Brisbane', + 'Tasmania' => 'Australia/Hobart', + 'Vladivostok' => 'Asia/Vladivostok', + 'West Pacific' => 'Pacific/Guam', + 'Central Pacific' => 'Asia/Magadan', + 'Fiji' => 'Pacific/Fiji', + 'New Zealand' => 'Pacific/Auckland', + 'Tonga' => 'Pacific/Tongatapu', ]; diff --git a/vendor/sabre/vobject/lib/timezonedata/php-workaround.php b/vendor/sabre/vobject/lib/timezonedata/php-workaround.php index 6b9cb6ef7..13ff4b302 100644 --- a/vendor/sabre/vobject/lib/timezonedata/php-workaround.php +++ b/vendor/sabre/vobject/lib/timezonedata/php-workaround.php @@ -15,32 +15,32 @@ * @license http://sabre.io/license/ Modified BSD License */ return [ - 'CST6CDT' => 'America/Chicago', - 'Cuba' => 'America/Havana', - 'Egypt' => 'Africa/Cairo', - 'Eire' => 'Europe/Dublin', - 'EST5EDT' => 'America/New_York', - 'Factory' => 'UTC', - 'GB-Eire' => 'Europe/London', - 'GMT0' => 'UTC', + 'CST6CDT' => 'America/Chicago', + 'Cuba' => 'America/Havana', + 'Egypt' => 'Africa/Cairo', + 'Eire' => 'Europe/Dublin', + 'EST5EDT' => 'America/New_York', + 'Factory' => 'UTC', + 'GB-Eire' => 'Europe/London', + 'GMT0' => 'UTC', 'Greenwich' => 'UTC', - 'Hongkong' => 'Asia/Hong_Kong', - 'Iceland' => 'Atlantic/Reykjavik', - 'Iran' => 'Asia/Tehran', - 'Israel' => 'Asia/Jerusalem', - 'Jamaica' => 'America/Jamaica', - 'Japan' => 'Asia/Tokyo', + 'Hongkong' => 'Asia/Hong_Kong', + 'Iceland' => 'Atlantic/Reykjavik', + 'Iran' => 'Asia/Tehran', + 'Israel' => 'Asia/Jerusalem', + 'Jamaica' => 'America/Jamaica', + 'Japan' => 'Asia/Tokyo', 'Kwajalein' => 'Pacific/Kwajalein', - 'Libya' => 'Africa/Tripoli', - 'MST7MDT' => 'America/Denver', - 'Navajo' => 'America/Denver', - 'NZ-CHAT' => 'Pacific/Chatham', - 'Poland' => 'Europe/Warsaw', - 'Portugal' => 'Europe/Lisbon', - 'PST8PDT' => 'America/Los_Angeles', + 'Libya' => 'Africa/Tripoli', + 'MST7MDT' => 'America/Denver', + 'Navajo' => 'America/Denver', + 'NZ-CHAT' => 'Pacific/Chatham', + 'Poland' => 'Europe/Warsaw', + 'Portugal' => 'Europe/Lisbon', + 'PST8PDT' => 'America/Los_Angeles', 'Singapore' => 'Asia/Singapore', - 'Turkey' => 'Europe/Istanbul', + 'Turkey' => 'Europe/Istanbul', 'Universal' => 'UTC', - 'W-SU' => 'Europe/Moscow', - 'Zulu' => 'UTC', + 'W-SU' => 'Europe/Moscow', + 'Zulu' => 'UTC', ]; diff --git a/vendor/sabre/vobject/lib/timezonedata/windowszones.php b/vendor/sabre/vobject/lib/timezonedata/windowszones.php index 29f3a6cb8..af3904b12 100644 --- a/vendor/sabre/vobject/lib/timezonedata/windowszones.php +++ b/vendor/sabre/vobject/lib/timezonedata/windowszones.php @@ -1,7 +1,7 @@ <?php /** - * Automatically generated timezone file + * Automatically generated timezone file. * * Last update: 2016-08-24T17:35:38-04:00 * Source: http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml @@ -11,133 +11,133 @@ */ return [ - 'AUS Central Standard Time' => 'Australia/Darwin', - 'AUS Eastern Standard Time' => 'Australia/Sydney', - 'Afghanistan Standard Time' => 'Asia/Kabul', - 'Alaskan Standard Time' => 'America/Anchorage', - 'Aleutian Standard Time' => 'America/Adak', - 'Altai Standard Time' => 'Asia/Barnaul', - 'Arab Standard Time' => 'Asia/Riyadh', - 'Arabian Standard Time' => 'Asia/Dubai', - 'Arabic Standard Time' => 'Asia/Baghdad', - 'Argentina Standard Time' => 'America/Buenos_Aires', - 'Astrakhan Standard Time' => 'Europe/Astrakhan', - 'Atlantic Standard Time' => 'America/Halifax', - 'Aus Central W. Standard Time' => 'Australia/Eucla', - 'Azerbaijan Standard Time' => 'Asia/Baku', - 'Azores Standard Time' => 'Atlantic/Azores', - 'Bahia Standard Time' => 'America/Bahia', - 'Bangladesh Standard Time' => 'Asia/Dhaka', - 'Belarus Standard Time' => 'Europe/Minsk', - 'Bougainville Standard Time' => 'Pacific/Bougainville', - 'Canada Central Standard Time' => 'America/Regina', - 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde', - 'Caucasus Standard Time' => 'Asia/Yerevan', - 'Cen. Australia Standard Time' => 'Australia/Adelaide', - 'Central America Standard Time' => 'America/Guatemala', - 'Central Asia Standard Time' => 'Asia/Almaty', + 'AUS Central Standard Time' => 'Australia/Darwin', + 'AUS Eastern Standard Time' => 'Australia/Sydney', + 'Afghanistan Standard Time' => 'Asia/Kabul', + 'Alaskan Standard Time' => 'America/Anchorage', + 'Aleutian Standard Time' => 'America/Adak', + 'Altai Standard Time' => 'Asia/Barnaul', + 'Arab Standard Time' => 'Asia/Riyadh', + 'Arabian Standard Time' => 'Asia/Dubai', + 'Arabic Standard Time' => 'Asia/Baghdad', + 'Argentina Standard Time' => 'America/Buenos_Aires', + 'Astrakhan Standard Time' => 'Europe/Astrakhan', + 'Atlantic Standard Time' => 'America/Halifax', + 'Aus Central W. Standard Time' => 'Australia/Eucla', + 'Azerbaijan Standard Time' => 'Asia/Baku', + 'Azores Standard Time' => 'Atlantic/Azores', + 'Bahia Standard Time' => 'America/Bahia', + 'Bangladesh Standard Time' => 'Asia/Dhaka', + 'Belarus Standard Time' => 'Europe/Minsk', + 'Bougainville Standard Time' => 'Pacific/Bougainville', + 'Canada Central Standard Time' => 'America/Regina', + 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde', + 'Caucasus Standard Time' => 'Asia/Yerevan', + 'Cen. Australia Standard Time' => 'Australia/Adelaide', + 'Central America Standard Time' => 'America/Guatemala', + 'Central Asia Standard Time' => 'Asia/Almaty', 'Central Brazilian Standard Time' => 'America/Cuiaba', - 'Central Europe Standard Time' => 'Europe/Budapest', - 'Central European Standard Time' => 'Europe/Warsaw', - 'Central Pacific Standard Time' => 'Pacific/Guadalcanal', - 'Central Standard Time' => 'America/Chicago', - 'Central Standard Time (Mexico)' => 'America/Mexico_City', - 'Chatham Islands Standard Time' => 'Pacific/Chatham', - 'China Standard Time' => 'Asia/Shanghai', - 'Cuba Standard Time' => 'America/Havana', - 'Dateline Standard Time' => 'Etc/GMT+12', - 'E. Africa Standard Time' => 'Africa/Nairobi', - 'E. Australia Standard Time' => 'Australia/Brisbane', - 'E. Europe Standard Time' => 'Europe/Chisinau', - 'E. South America Standard Time' => 'America/Sao_Paulo', - 'Easter Island Standard Time' => 'Pacific/Easter', - 'Eastern Standard Time' => 'America/New_York', - 'Eastern Standard Time (Mexico)' => 'America/Cancun', - 'Egypt Standard Time' => 'Africa/Cairo', - 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg', - 'FLE Standard Time' => 'Europe/Kiev', - 'Fiji Standard Time' => 'Pacific/Fiji', - 'GMT Standard Time' => 'Europe/London', - 'GTB Standard Time' => 'Europe/Bucharest', - 'Georgian Standard Time' => 'Asia/Tbilisi', - 'Greenland Standard Time' => 'America/Godthab', - 'Greenwich Standard Time' => 'Atlantic/Reykjavik', - 'Haiti Standard Time' => 'America/Port-au-Prince', - 'Hawaiian Standard Time' => 'Pacific/Honolulu', - 'India Standard Time' => 'Asia/Calcutta', - 'Iran Standard Time' => 'Asia/Tehran', - 'Israel Standard Time' => 'Asia/Jerusalem', - 'Jordan Standard Time' => 'Asia/Amman', - 'Kaliningrad Standard Time' => 'Europe/Kaliningrad', - 'Korea Standard Time' => 'Asia/Seoul', - 'Libya Standard Time' => 'Africa/Tripoli', - 'Line Islands Standard Time' => 'Pacific/Kiritimati', - 'Lord Howe Standard Time' => 'Australia/Lord_Howe', - 'Magadan Standard Time' => 'Asia/Magadan', - 'Marquesas Standard Time' => 'Pacific/Marquesas', - 'Mauritius Standard Time' => 'Indian/Mauritius', - 'Middle East Standard Time' => 'Asia/Beirut', - 'Montevideo Standard Time' => 'America/Montevideo', - 'Morocco Standard Time' => 'Africa/Casablanca', - 'Mountain Standard Time' => 'America/Denver', + 'Central Europe Standard Time' => 'Europe/Budapest', + 'Central European Standard Time' => 'Europe/Warsaw', + 'Central Pacific Standard Time' => 'Pacific/Guadalcanal', + 'Central Standard Time' => 'America/Chicago', + 'Central Standard Time (Mexico)' => 'America/Mexico_City', + 'Chatham Islands Standard Time' => 'Pacific/Chatham', + 'China Standard Time' => 'Asia/Shanghai', + 'Cuba Standard Time' => 'America/Havana', + 'Dateline Standard Time' => 'Etc/GMT+12', + 'E. Africa Standard Time' => 'Africa/Nairobi', + 'E. Australia Standard Time' => 'Australia/Brisbane', + 'E. Europe Standard Time' => 'Europe/Chisinau', + 'E. South America Standard Time' => 'America/Sao_Paulo', + 'Easter Island Standard Time' => 'Pacific/Easter', + 'Eastern Standard Time' => 'America/New_York', + 'Eastern Standard Time (Mexico)' => 'America/Cancun', + 'Egypt Standard Time' => 'Africa/Cairo', + 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg', + 'FLE Standard Time' => 'Europe/Kiev', + 'Fiji Standard Time' => 'Pacific/Fiji', + 'GMT Standard Time' => 'Europe/London', + 'GTB Standard Time' => 'Europe/Bucharest', + 'Georgian Standard Time' => 'Asia/Tbilisi', + 'Greenland Standard Time' => 'America/Godthab', + 'Greenwich Standard Time' => 'Atlantic/Reykjavik', + 'Haiti Standard Time' => 'America/Port-au-Prince', + 'Hawaiian Standard Time' => 'Pacific/Honolulu', + 'India Standard Time' => 'Asia/Calcutta', + 'Iran Standard Time' => 'Asia/Tehran', + 'Israel Standard Time' => 'Asia/Jerusalem', + 'Jordan Standard Time' => 'Asia/Amman', + 'Kaliningrad Standard Time' => 'Europe/Kaliningrad', + 'Korea Standard Time' => 'Asia/Seoul', + 'Libya Standard Time' => 'Africa/Tripoli', + 'Line Islands Standard Time' => 'Pacific/Kiritimati', + 'Lord Howe Standard Time' => 'Australia/Lord_Howe', + 'Magadan Standard Time' => 'Asia/Magadan', + 'Marquesas Standard Time' => 'Pacific/Marquesas', + 'Mauritius Standard Time' => 'Indian/Mauritius', + 'Middle East Standard Time' => 'Asia/Beirut', + 'Montevideo Standard Time' => 'America/Montevideo', + 'Morocco Standard Time' => 'Africa/Casablanca', + 'Mountain Standard Time' => 'America/Denver', 'Mountain Standard Time (Mexico)' => 'America/Chihuahua', - 'Myanmar Standard Time' => 'Asia/Rangoon', - 'N. Central Asia Standard Time' => 'Asia/Novosibirsk', - 'Namibia Standard Time' => 'Africa/Windhoek', - 'Nepal Standard Time' => 'Asia/Katmandu', - 'New Zealand Standard Time' => 'Pacific/Auckland', - 'Newfoundland Standard Time' => 'America/St_Johns', - 'Norfolk Standard Time' => 'Pacific/Norfolk', - 'North Asia East Standard Time' => 'Asia/Irkutsk', - 'North Asia Standard Time' => 'Asia/Krasnoyarsk', - 'North Korea Standard Time' => 'Asia/Pyongyang', - 'Pacific SA Standard Time' => 'America/Santiago', - 'Pacific Standard Time' => 'America/Los_Angeles', - 'Pacific Standard Time (Mexico)' => 'America/Tijuana', - 'Pakistan Standard Time' => 'Asia/Karachi', - 'Paraguay Standard Time' => 'America/Asuncion', - 'Romance Standard Time' => 'Europe/Paris', - 'Russia Time Zone 10' => 'Asia/Srednekolymsk', - 'Russia Time Zone 11' => 'Asia/Kamchatka', - 'Russia Time Zone 3' => 'Europe/Samara', - 'Russian Standard Time' => 'Europe/Moscow', - 'SA Eastern Standard Time' => 'America/Cayenne', - 'SA Pacific Standard Time' => 'America/Bogota', - 'SA Western Standard Time' => 'America/La_Paz', - 'SE Asia Standard Time' => 'Asia/Bangkok', - 'Saint Pierre Standard Time' => 'America/Miquelon', - 'Sakhalin Standard Time' => 'Asia/Sakhalin', - 'Samoa Standard Time' => 'Pacific/Apia', - 'Singapore Standard Time' => 'Asia/Singapore', - 'South Africa Standard Time' => 'Africa/Johannesburg', - 'Sri Lanka Standard Time' => 'Asia/Colombo', - 'Syria Standard Time' => 'Asia/Damascus', - 'Taipei Standard Time' => 'Asia/Taipei', - 'Tasmania Standard Time' => 'Australia/Hobart', - 'Tocantins Standard Time' => 'America/Araguaina', - 'Tokyo Standard Time' => 'Asia/Tokyo', - 'Tomsk Standard Time' => 'Asia/Tomsk', - 'Tonga Standard Time' => 'Pacific/Tongatapu', - 'Transbaikal Standard Time' => 'Asia/Chita', - 'Turkey Standard Time' => 'Europe/Istanbul', - 'Turks And Caicos Standard Time' => 'America/Grand_Turk', - 'US Eastern Standard Time' => 'America/Indianapolis', - 'US Mountain Standard Time' => 'America/Phoenix', - 'UTC' => 'Etc/GMT', - 'UTC+12' => 'Etc/GMT-12', - 'UTC-02' => 'Etc/GMT+2', - 'UTC-08' => 'Etc/GMT+8', - 'UTC-09' => 'Etc/GMT+9', - 'UTC-11' => 'Etc/GMT+11', - 'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar', - 'Venezuela Standard Time' => 'America/Caracas', - 'Vladivostok Standard Time' => 'Asia/Vladivostok', - 'W. Australia Standard Time' => 'Australia/Perth', + 'Myanmar Standard Time' => 'Asia/Rangoon', + 'N. Central Asia Standard Time' => 'Asia/Novosibirsk', + 'Namibia Standard Time' => 'Africa/Windhoek', + 'Nepal Standard Time' => 'Asia/Katmandu', + 'New Zealand Standard Time' => 'Pacific/Auckland', + 'Newfoundland Standard Time' => 'America/St_Johns', + 'Norfolk Standard Time' => 'Pacific/Norfolk', + 'North Asia East Standard Time' => 'Asia/Irkutsk', + 'North Asia Standard Time' => 'Asia/Krasnoyarsk', + 'North Korea Standard Time' => 'Asia/Pyongyang', + 'Pacific SA Standard Time' => 'America/Santiago', + 'Pacific Standard Time' => 'America/Los_Angeles', + 'Pacific Standard Time (Mexico)' => 'America/Tijuana', + 'Pakistan Standard Time' => 'Asia/Karachi', + 'Paraguay Standard Time' => 'America/Asuncion', + 'Romance Standard Time' => 'Europe/Paris', + 'Russia Time Zone 10' => 'Asia/Srednekolymsk', + 'Russia Time Zone 11' => 'Asia/Kamchatka', + 'Russia Time Zone 3' => 'Europe/Samara', + 'Russian Standard Time' => 'Europe/Moscow', + 'SA Eastern Standard Time' => 'America/Cayenne', + 'SA Pacific Standard Time' => 'America/Bogota', + 'SA Western Standard Time' => 'America/La_Paz', + 'SE Asia Standard Time' => 'Asia/Bangkok', + 'Saint Pierre Standard Time' => 'America/Miquelon', + 'Sakhalin Standard Time' => 'Asia/Sakhalin', + 'Samoa Standard Time' => 'Pacific/Apia', + 'Singapore Standard Time' => 'Asia/Singapore', + 'South Africa Standard Time' => 'Africa/Johannesburg', + 'Sri Lanka Standard Time' => 'Asia/Colombo', + 'Syria Standard Time' => 'Asia/Damascus', + 'Taipei Standard Time' => 'Asia/Taipei', + 'Tasmania Standard Time' => 'Australia/Hobart', + 'Tocantins Standard Time' => 'America/Araguaina', + 'Tokyo Standard Time' => 'Asia/Tokyo', + 'Tomsk Standard Time' => 'Asia/Tomsk', + 'Tonga Standard Time' => 'Pacific/Tongatapu', + 'Transbaikal Standard Time' => 'Asia/Chita', + 'Turkey Standard Time' => 'Europe/Istanbul', + 'Turks And Caicos Standard Time' => 'America/Grand_Turk', + 'US Eastern Standard Time' => 'America/Indianapolis', + 'US Mountain Standard Time' => 'America/Phoenix', + 'UTC' => 'Etc/GMT', + 'UTC+12' => 'Etc/GMT-12', + 'UTC-02' => 'Etc/GMT+2', + 'UTC-08' => 'Etc/GMT+8', + 'UTC-09' => 'Etc/GMT+9', + 'UTC-11' => 'Etc/GMT+11', + 'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar', + 'Venezuela Standard Time' => 'America/Caracas', + 'Vladivostok Standard Time' => 'Asia/Vladivostok', + 'W. Australia Standard Time' => 'Australia/Perth', 'W. Central Africa Standard Time' => 'Africa/Lagos', - 'W. Europe Standard Time' => 'Europe/Berlin', - 'W. Mongolia Standard Time' => 'Asia/Hovd', - 'West Asia Standard Time' => 'Asia/Tashkent', - 'West Bank Standard Time' => 'Asia/Hebron', - 'West Pacific Standard Time' => 'Pacific/Port_Moresby', - 'Yakutsk Standard Time' => 'Asia/Yakutsk', + 'W. Europe Standard Time' => 'Europe/Berlin', + 'W. Mongolia Standard Time' => 'Asia/Hovd', + 'West Asia Standard Time' => 'Asia/Tashkent', + 'West Bank Standard Time' => 'Asia/Hebron', + 'West Pacific Standard Time' => 'Pacific/Port_Moresby', + 'Yakutsk Standard Time' => 'Asia/Yakutsk', ]; diff --git a/vendor/sabre/vobject/phpstan.neon b/vendor/sabre/vobject/phpstan.neon new file mode 100644 index 000000000..e50c5be6e --- /dev/null +++ b/vendor/sabre/vobject/phpstan.neon @@ -0,0 +1,3 @@ +parameters: + level: 0 + bootstrap: %currentWorkingDirectory%/vendor/autoload.php diff --git a/vendor/sabre/vobject/tests/bootstrap.php b/vendor/sabre/vobject/tests/bootstrap.php index 14281e218..46e9014cb 100644 --- a/vendor/sabre/vobject/tests/bootstrap.php +++ b/vendor/sabre/vobject/tests/bootstrap.php @@ -3,8 +3,8 @@ date_default_timezone_set('UTC'); $try = [ - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/../../../autoload.php', + __DIR__.'/../vendor/autoload.php', + __DIR__.'/../../../autoload.php', ]; foreach ($try as $path) { @@ -14,12 +14,12 @@ foreach ($try as $path) { } } -$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__ . '/VObject'); +$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__.'/VObject'); if (!defined('SABRE_TEMPDIR')) { - define('SABRE_TEMPDIR', __DIR__ . '/temp/'); + define('SABRE_TEMPDIR', __DIR__.'/temp/'); } if (!file_exists(SABRE_TEMPDIR)) { - mkdir(SABRE_TEMPDIR); + mkdir(SABRE_TEMPDIR); } diff --git a/view/css/cdav_calendar.css b/view/css/cdav_calendar.css index 2deff683c..da594b420 100644 --- a/view/css/cdav_calendar.css +++ b/view/css/cdav_calendar.css @@ -29,3 +29,9 @@ main.fullscreen .fc td:last-child { .fc-list-view { border-width: 0px; } + +.bootstrap-tagsinput { + width: 100%; + padding: 6px 12px; +} + diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 18c3db665..3bee84378 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -942,17 +942,18 @@ a .generic-icons { color: $font_colour; } -.generic-icons:hover, -a .generic-icons:hover { - color: $font_colour; -} - .generic-icons-right { font-size: 1rem; margin-left: 0.5rem; color: $font_colour; } +.generic-icons:hover, +a .generic-icons:hover, +.generic-icons-right:hover, +a .generic-icons-right:hover { + color: $font_colour; +} .generic-icons-nav { font-size: 1rem; diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl index cf4542bbe..5c2f0080b 100644 --- a/view/tpl/cdav_calendar.tpl +++ b/view/tpl/cdav_calendar.tpl @@ -4,6 +4,14 @@ var new_event = {}; var new_event_id = Math.random().toString(36).substring(7); var views = {'dayGridMonth' : '{{$month}}', 'timeGridWeek' : '{{$week}}', 'timeGridDay' : '{{$day}}', 'listMonth' : '{{$list_month}}', 'listWeek' : '{{$list_week}}', 'listDay' : '{{$list_day}}'}; +var event_id; +var event_uri; + +var contact_allow = []; +var group_allow = []; +var contact_deny = []; +var group_deny = []; + $(document).ready(function() { var calendarEl = document.getElementById('calendar'); calendar = new FullCalendar.Calendar(calendarEl, { @@ -45,7 +53,7 @@ $(document).ready(function() { dtend.setHours(dtend.getHours() + 1); } - $('#event_uri').val(''); + event_uri = ''; $('#id_title').val('New event'); $('#calendar_select').val($("#calendar_select option:first").val()).attr('disabled', false); $('#id_dtstart').val(info.date.toUTCString()); @@ -61,15 +69,32 @@ $(document).ready(function() { eventClick: function(info) { + //reset categories + $('#id_categories').tagsinput('removeAll'); + var event = info.event._def; var dtstart = new Date(info.event._instance.range.start); var dtend = new Date(info.event._instance.range.end); - + console.log(event.extendedProps.categories); + if(event.extendedProps.plink) { + if(! $('#l2s').length) + $('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>'); + + $('#l2s').html('<a href="' + event.extendedProps.plink[0] + '" target="_blank"><i class="fa fa-external-link"></i> ' + event.extendedProps.plink[1] + '</a>'); + } + else { + $('#l2s').remove(); + } + if(event.publicId == new_event_id) { + $('#calendar_select').trigger('change'); + $('#event_submit').show(); + event_id = 0; $(window).scrollTop(0); $('.section-content-tools-wrapper, #event_form_wrapper').show(); $('#recurrence_warning').hide(); $('#id_title').focus().val(''); + return false; } @@ -79,18 +104,29 @@ $(document).ready(function() { new_event = {}; } + var calendar_id = ((event.extendedProps.calendar_id.constructor === Array) ? event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1] : event.extendedProps.calendar_id); + if(!event.extendedProps.recurrent) { $(window).scrollTop(0); $('.section-content-tools-wrapper, #event_form_wrapper').show(); $('#recurrence_warning').hide(); - $('#event_uri').val(event.extendedProps.uri); + event_uri = event.extendedProps.uri; $('#id_title').val(event.title); - $('#calendar_select').val(event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1]).attr('disabled', true); + $('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change'); + $('#id_categories').tagsinput('add', event.extendedProps.categories); $('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtend').val(dtend.toUTCString()); $('#id_description').val(event.extendedProps.description); $('#id_location').val(event.extendedProps.location); $('#event_submit').val('update_event').html('{{$update}}'); + $('#dbtn-acl').addClass('d-none'); + event_id = event.extendedProps.item ? event.extendedProps.item.id : 0; + + contact_allow = event.extendedProps.contact_allow || []; + group_allow = event.extendedProps.group_allow || []; + contact_deny = event.extendedProps.contact_deny || []; + group_deny = event.extendedProps.group_deny || []; + if(event.extendedProps.rw) { $('#event_delete').show(); $('#event_submit').show(); @@ -100,6 +136,11 @@ $(document).ready(function() { $('#id_dtend').attr('disabled', false); $('#id_description').attr('disabled', false); $('#id_location').attr('disabled', false); + + if(calendar_id == 'channel_calendar' && !event.extendedProps.is_editable) { + console.log(calendar_id) + $('#event_submit').hide(); + } } else { $('#event_submit').hide(); @@ -114,8 +155,8 @@ $(document).ready(function() { else if(event.extendedProps.recurrent && event.extendedProps.rw) { $('.section-content-tools-wrapper, #recurrence_warning').show(); $('#event_form_wrapper').hide(); - $('#event_uri').val(event.extendedProps.uri); - $('#calendar_select').val(event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1]).attr('disabled', true); + event_uri = event.extendedProps.uri; + $('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change'); } }, @@ -193,6 +234,13 @@ $(document).ready(function() { calendar.next(); $('#title').text(calendar.view.title); }); + + $('#calendar_select').on('change', function() { + if(this.value === 'channel_calendar') + $('#dbtn-acl, #id_categories_wrapper').removeClass('d-none'); + else + $('#dbtn-acl, #id_categories_wrapper').addClass('d-none'); + }); $('.color-edit').colorpicker({ input: '.color-edit-input' }); @@ -213,9 +261,16 @@ function changeView(action, viewName) { } function add_remove_json_source(source, color, editable, status) { - var parts = source.split('/'); - var id = parts[4]; - + var id, parts = []; + + if(source == '/channel_calendar/json') + id = 'channel_calendar' + + if(! id) { + parts = source.split('/'); + id = parts[4]; + } + var eventSource = calendar.getEventSourceById(id); var selector = '#calendar-btn-' + id; @@ -247,37 +302,102 @@ function updateSize() { } function on_submit() { - $.post( 'cdav/calendar', { - 'submit': $('#event_submit').val(), - 'target': $('#calendar_select').val(), - 'uri': $('#event_uri').val(), - 'title': $('#id_title').val(), - 'dtstart': $('#id_dtstart').val(), - 'dtend': $('#id_dtend').val(), - 'description': $('#id_description').val(), - 'location': $('#id_location').val() - }) - .done(function() { - var parts = $('#calendar_select').val().split(':'); - var eventSource = calendar.getEventSourceById(parts[0]); - eventSource.refetch(); - reset_form(); + if($('#calendar_select').val() == 'channel_calendar') { + if(new_event_id) { + $("input[name='contact_allow[]']").each(function() { + contact_allow.push($(this).val()); + }); + $("input[name='group_allow[]']").each(function() { + group_allow.push($(this).val()); + }); + $("input[name='contact_deny[]']").each(function() { + contact_deny.push($(this).val()); + }); + $("input[name='group_deny[]']").each(function() { + group_deny.push($(this).val()); + }); + } - }); + $.post( 'channel_calendar', { + 'event_id': event_id, + 'event_hash': event_uri, + 'xchan': '{{$channel_hash}}', + //'mid': mid, + 'type': 'event', + 'preview': 0, + 'summary': $('#id_title').val(), + 'dtstart': $('#id_dtstart').val(), + 'dtend': $('#id_dtend').val(), + 'adjust': 0, + 'categories': $('#id_categories').val(), + 'desc': $('#id_description').val(), + 'location': $('#id_location').val(), + 'submit': $('#event_submit').val(), + 'contact_allow[]': contact_allow, + 'group_allow[]': group_allow, + 'contact_deny[]': contact_deny, + 'group_deny[]': group_deny +/* + 'submit': $('#event_submit').val(), + 'target': $('#calendar_select').val(), + 'uri': $('#event_uri').val(), + 'title': $('#id_title').val(), + 'dtstart': $('#id_dtstart').val(), + 'dtend': $('#id_dtend').val(), + 'description': $('#id_description').val(), + 'location': $('#id_location').val() +*/ + }) + .done(function() { + var eventSource = calendar.getEventSourceById('channel_calendar'); + eventSource.refetch(); + reset_form(); + + }); + + } + else { + $.post( 'cdav/calendar', { + 'submit': $('#event_submit').val(), + 'target': $('#calendar_select').val(), + 'uri': event_uri, + 'title': $('#id_title').val(), + 'dtstart': $('#id_dtstart').val(), + 'dtend': $('#id_dtend').val(), + 'description': $('#id_description').val(), + 'location': $('#id_location').val() + }) + .done(function() { + var parts = $('#calendar_select').val().split(':'); + var eventSource = calendar.getEventSourceById(parts[0]); + eventSource.refetch(); + reset_form(); + + }); + } } function on_delete() { - $.post( 'cdav/calendar', { - 'delete': 'delete', - 'target': $('#calendar_select').val(), - 'uri': $('#event_uri').val(), - }) - .done(function() { - var parts = $('#calendar_select').val().split(':'); - var eventSource = calendar.getEventSourceById(parts[0]); - eventSource.refetch(); - reset_form(); - }); + if($('#calendar_select').val() == 'channel_calendar') { + $.get('channel_calendar/drop/' + event_uri, function() { + var eventSource = calendar.getEventSourceById('channel_calendar'); + eventSource.refetch(); + reset_form(); + }); + } + else { + $.post( 'cdav/calendar', { + 'delete': 'delete', + 'target': $('#calendar_select').val(), + 'uri': event_uri + }) + .done(function() { + var parts = $('#calendar_select').val().split(':'); + var eventSource = calendar.getEventSourceById(parts[0]); + eventSource.refetch(); + reset_form(); + }); + } } function reset_form() { @@ -285,8 +405,9 @@ function reset_form() { $('#event_submit').val(''); $('#calendar_select').val(''); - $('#event_uri').val(''); + event_uri = ''; $('#id_title').val(''); + $('#id_categories').tagsinput('removeAll'); $('#id_dtstart').val(''); $('#id_dtend').val(''); @@ -311,6 +432,14 @@ function on_more() { } } +function exportDate() { + alert('not implemented'); + console.log('not implemented'); + //var moment = $('#events-calendar').fullCalendar('getDate'); + //var sT = 'events/' + moment.year() + '/' + (moment.month() + 1) + '/export'; + //window.location.href=sT; +} + </script> <div class="generic-content-wrapper"> @@ -350,16 +479,28 @@ function on_more() { </div> </div> <div id="event_form_wrapper" style="display: none"> - <form id="event_form" method="post" action=""> - <input id="event_uri" type="hidden" name="uri" value=""> + <form id="event_form" method="post" action="" class="acl-form" data-form_id="event_form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> {{include file="field_input.tpl" field=$title}} <label for="calendar_select">{{$calendar_select_label}}</label> <select id="calendar_select" name="target" class="form-control form-group"> + <optgroup label="{{$calendar_optiopns_label.0}}"> + {{foreach $channel_calendars as $channel_calendar}} + <option value="channel_calendar">{{$channel_calendar.displayname}}</option> + {{/foreach}} + </optgroup> + <optgroup label="{{$calendar_optiopns_label.1}}"> {{foreach $writable_calendars as $writable_calendar}} <option value="{{$writable_calendar.id.0}}:{{$writable_calendar.id.1}}">{{$writable_calendar.displayname}}{{if $writable_calendar.sharer}} ({{$writable_calendar.sharer}}){{/if}}</option> {{/foreach}} + </optgroup> </select> <div id="more_block" style="display: none;"> + {{if $catsenabled}} + <div id="id_categories_wrapper" class="form-group"> + <label id="label_categories" for="id_categories">{{$categories_label}}</label> + <input name="categories" id="id_categories" class="form-control" type="text" value="{{$categories}}" data-role="cat-tagsinput" /> + </div> + {{/if}} {{include file="field_input.tpl" field=$dtstart}} {{include file="field_input.tpl" field=$dtend}} {{include file="field_textarea.tpl" field=$description}} @@ -368,6 +509,7 @@ function on_more() { <div class="form-group"> <div class="pull-right"> <button id="event_more" type="button" class="btn btn-outline-secondary btn-sm"><i class="fa fa-caret-down"></i> {{$more}}</button> + <button id="dbtn-acl" class="btn btn-outline-secondary btn-sm d-none" type="button" data-toggle="modal" data-target="#aclModal"><i id="jot-perms-icon" class="fa fa-{{$lockstate}}"></i></button> <button id="event_submit" type="button" value="" class="btn btn-primary btn-sm"></button> </div> @@ -378,6 +520,7 @@ function on_more() { <div class="clear"></div> </div> </form> + {{$acl}} </div> </div> <div class="section-content-wrapper-np"> diff --git a/view/tpl/cdav_widget_calendar.tpl b/view/tpl/cdav_widget_calendar.tpl index 8d6414ec6..a538cd26d 100644 --- a/view/tpl/cdav_widget_calendar.tpl +++ b/view/tpl/cdav_widget_calendar.tpl @@ -1,3 +1,17 @@ +<div class="widget"> + <h3>{{$channel_calendars_label}}</h3> + {{foreach $channel_calendars as $channel_calendar}} + <div id="calendar-{{$channel_calendar.calendarid}}"> + <div class="ml-3{{if !$channel_calendar@last}} form-group{{/if}}"> + <i id="calendar-btn-{{$channel_calendar.calendarid}}" class="fa {{if $channel_calendar.switch}}fa-calendar-check-o{{else}}fa-calendar-o{{/if}} generic-icons fakelink" onclick="add_remove_json_source('{{$channel_calendar.json_source}}', '{{$channel_calendar.color}}', {{$channel_calendar.editable}})" style="color: {{$channel_calendar.color}};"></i>{{$channel_calendar.displayname}} + <div class="float-right"> + <a href="#" onclick="exportDate(); return false;"><i id="download-icon" class="fa fa-cloud-download fakelink generic-icons-right"></i></a> + </div> + </div> + </div> + {{/foreach}} +</div> + {{if $my_calendars}} <div class="widget"> <h3>{{$my_calendars_label}}</h3> diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index afaaa62d9..7b1f4ee05 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -354,7 +354,7 @@ var activeCommentText = ''; } function itemAddToCal(id) { - $.get('{{$baseurl}}/events/add/' + id); + $.get('{{$baseurl}}/channel_calendar/add/' + id); if(timer) clearTimeout(timer); timer = setTimeout(updateInit,1000); } |