Browse Source

Merge remote-tracking branch 'upstream/master' into disroot_master

disroot_master
Muppeth 1 year ago
parent
commit
f3f0edba8f
100 changed files with 5071 additions and 4377 deletions
  1. +58
    -37
      .gitlab-ci.yml
  2. +46
    -140
      .homeinstall/README.md
  3. +7
    -4
      .homeinstall/hubzilla-config.txt.template
  4. +61
    -230
      .homeinstall/hubzilla-setup.sh
  5. +58
    -0
      CHANGELOG
  6. +91
    -50
      Zotlabs/Lib/Activity.php
  7. +2
    -3
      Zotlabs/Lib/Apps.php
  8. +8
    -1
      Zotlabs/Lib/DB_Upgrade.php
  9. +1
    -1
      Zotlabs/Lib/Libzot.php
  10. +13
    -13
      Zotlabs/Lib/ThreadItem.php
  11. +43
    -2
      Zotlabs/Module/Admin/Dbsync.php
  12. +57
    -0
      Zotlabs/Module/Apschema.php
  13. +22
    -14
      Zotlabs/Module/Cal.php
  14. +184
    -51
      Zotlabs/Module/Cdav.php
  15. +7
    -11
      Zotlabs/Module/Channel.php
  16. +441
    -0
      Zotlabs/Module/Channel_calendar.php
  17. +26
    -17
      Zotlabs/Module/Cover_photo.php
  18. +33
    -5
      Zotlabs/Module/Directory.php
  19. +2
    -1
      Zotlabs/Module/Editpost.php
  20. +34
    -14
      Zotlabs/Module/Embedphotos.php
  21. +9
    -4
      Zotlabs/Module/Getfile.php
  22. +3
    -3
      Zotlabs/Module/Like.php
  23. +44
    -1
      Zotlabs/Module/Linkinfo.php
  24. +31
    -42
      Zotlabs/Module/Photo.php
  25. +35
    -77
      Zotlabs/Module/Photos.php
  26. +1
    -1
      Zotlabs/Module/Ping.php
  27. +37
    -0
      Zotlabs/Module/Poster.php
  28. +65
    -25
      Zotlabs/Module/Profile_photo.php
  29. +8
    -0
      Zotlabs/Module/React.php
  30. +8
    -4
      Zotlabs/Module/Register.php
  31. +2
    -2
      Zotlabs/Module/Search.php
  32. +1
    -1
      Zotlabs/Module/Settings/Calendar.php
  33. +19
    -2
      Zotlabs/Module/Wall_attach.php
  34. +4
    -4
      Zotlabs/Module/Wiki.php
  35. +36
    -4
      Zotlabs/Photo/PhotoDriver.php
  36. +10
    -6
      Zotlabs/Render/SmartyInterface.php
  37. +35
    -30
      Zotlabs/Render/SmartyTemplate.php
  38. +47
    -0
      Zotlabs/Update/_1232.php
  39. +38
    -0
      Zotlabs/Update/_1233.php
  40. +26
    -0
      Zotlabs/Update/_1234.php
  41. +1
    -2
      Zotlabs/Widget/Categories.php
  42. +18
    -5
      Zotlabs/Widget/Cdav.php
  43. +1
    -1
      Zotlabs/Widget/Notifications.php
  44. +3
    -3
      app/calendar.apd
  45. +0
    -6
      app/events.apd
  46. BIN
      app/events.png
  47. +5
    -4
      boot.php
  48. +1
    -1
      composer.json
  49. +17
    -18
      composer.lock
  50. +164
    -105
      doc/admin/administrator_guide.md
  51. +2
    -1
      doc/hidden_configs.bb
  52. +11
    -0
      include/attach.php
  53. +19
    -15
      include/bbcode.php
  54. +30
    -3
      include/connections.php
  55. +2
    -1
      include/datetime.php
  56. +25
    -0
      include/dba/dba_driver.php
  57. +1
    -1
      include/dba/dba_pdo.php
  58. +71
    -27
      include/event.php
  59. +17
    -17
      include/features.php
  60. +8
    -7
      include/follow.php
  61. +1
    -2
      include/html2bbcode.php
  62. +37
    -15
      include/import.php
  63. +1
    -1
      include/items.php
  64. +1
    -0
      include/js_strings.php
  65. +4
    -0
      include/markdown.php
  66. +16
    -15
      include/oembed.php
  67. +3
    -6
      include/photos.php
  68. +26
    -8
      include/text.php
  69. +49
    -33
      include/zot.php
  70. +1
    -1
      install/INSTALL.txt
  71. +0
    -1914
      install/database-w-defaults-v1131.diff
  72. +1
    -1
      install/htconfig.sample.php
  73. +3
    -20
      install/schema_mysql.sql
  74. +2
    -1
      install/schema_postgres.sql
  75. +5
    -0
      library/jgrowl/.gitignore
  76. +61
    -0
      library/jgrowl/Gruntfile.js
  77. +7
    -0
      library/jgrowl/LICENSE
  78. +0
    -3
      library/jgrowl/README
  79. +75
    -0
      library/jgrowl/README.md
  80. +32
    -0
      library/jgrowl/bower.json
  81. +103
    -0
      library/jgrowl/examples/appendTo.html
  82. +91
    -0
      library/jgrowl/examples/bootstrap.html
  83. +171
    -0
      library/jgrowl/examples/jgrowl.html
  84. +40
    -0
      library/jgrowl/jgrowl.jquery.json
  85. +100
    -1
      library/jgrowl/jquery.jgrowl.css
  86. +399
    -0
      library/jgrowl/jquery.jgrowl.js
  87. +1
    -0
      library/jgrowl/jquery.jgrowl.map
  88. +1
    -0
      library/jgrowl/jquery.jgrowl.min.css
  89. +1
    -1
      library/jgrowl/jquery.jgrowl.min.js
  90. +101
    -0
      library/jgrowl/less/jgrowl.core.less
  91. +2
    -0
      library/jgrowl/less/jgrowl.less
  92. +8
    -0
      library/jgrowl/less/jgrowl.variables.less
  93. +23
    -0
      library/jgrowl/package.json
  94. +92
    -65
      library/justifiedGallery/jquery.justifiedGallery.js
  95. +3
    -3
      library/justifiedGallery/jquery.justifiedGallery.min.js
  96. +14
    -6
      library/justifiedGallery/justifiedGallery.css
  97. +14
    -6
      library/justifiedGallery/justifiedGallery.min.css
  98. +1401
    -1257
      util/hmessages.po
  99. +1
    -1
      util/po2php.php
  100. +131
    -0
      util/storageconv

+ 58
- 37
.gitlab-ci.yml View File

@@ -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: {}


+ 46
- 140
.homeinstall/README.md View File

@@ -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


+ 7
- 4
.homeinstall/hubzilla-config.txt.template View File

@@ -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"


+ 61
- 230
.homeinstall/hubzilla-setup.sh View File

@@ -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


+ 58
- 0
CHANGELOG View File

@@ -1,3 +1,61 @@
Hubzilla 4.2 (2019-06-04)
- Introduce Calendar app which deprecates Events and CalDAV apps and streamlines the featuresets
- Update mod cal to reflect changes in the calendar app
- Improve timezone detection for CalDAV calendars
- Add mention support to event description in channel calendar
- Update jgrowl library
- Do not try to oembed URLs without embed tags
- Optimise pdf oembed processing
- Add form security token to mod register
- Replace URLs for mod gallery, mod photos and mod photo on cloned channel post sync
- Update justified gallery library
- Update bootstrap libraries
- Use "cache" flag for bbcode() on content destined for zot6
- Improve DB indexing
- Drop deprecated columns from channel the table
- Replace own image URL in clonned channel posts
- Improve DB update handling
- Improve item deletion when a contact was removed
- Zot6 compatibility for emoji reactions
- Add threaded comments support (disabled by default)
- Improve xmlify()/unxmlify() performance
- Update blueimp/jquery-file-uplad library
- Update sabre/vobject library
- Various doco updates
- Implement remove profile photo button (reset to default photo)
- Implement remove cover photo button
- Update the homeinstall script
- Add command line tool for photo thumbnails storage conversion
- Implement option to store photo thumbnails in filesystem instead of DB

Bugfixes
- Fix category widget when using articles
- Fix live update not triggering in mod search
- Fix encoded URLs in code blocks
- Fix wiki headers not escaped
- Fix possible xchan protocol confusion in new_contact()
- Fix xchan_url not displayed if xchan_addr not available
- Fix suggestion ordering in mod directory
- Fix event attachment delivery to zot6

Addons
- pubcrawl: improve friendica compatibility by adding the nonstandard diaspora:guid field
- pubcrawl: initial suport for events
- pubcrawl: improve permalink detection
- flashcards: fix moving learn buttons if viewport sizes changes
- flashcards: Move card details to the bottom of a card
- upgrade_info: provide links to changelog
- photocache: do not save filename for cached photos
- pubcrawl: save local comment activitypub payload in iconfig to be used for relay
- flashcards: UI improvements in box settings
- pubcrawl: implement profile update messages
- pubcrawl: use URI instead of object for actor
- flashcards: fix jumping sync button
- pubcrawl: add threaded comments support
- pubcrawl: ignore target encoding errors
- pubcrawl: format photo items for activitypub


Hubzilla 4.0.3 (2019-04-26)
- Add attachments to zot6 event objects
- Add zot6 to federated transports


+ 91
- 50
Zotlabs/Lib/Activity.php View File

@@ -5,6 +5,8 @@ namespace Zotlabs\Lib;
use Zotlabs\Daemon\Master;
use Zotlabs\Zot6\HTTPSig;

require_once('include/event.php');

class Activity {

static function encode_object($x) {
@@ -14,27 +16,30 @@ class Activity {
$x = json_decode($x,true);
}

if(is_array($x) && array_key_exists('asld',$x)) {
$x = $x['asld'];
}
if(is_array($x)) {

if($x['type'] === ACTIVITY_OBJ_PERSON) {
return self::fetch_person($x);
}
if($x['type'] === ACTIVITY_OBJ_PROFILE) {
return self::fetch_profile($x);
}
if(in_array($x['type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE ] )) {
return self::fetch_item($x);
}
if($x['type'] === ACTIVITY_OBJ_THING) {
return self::fetch_thing($x);
}
if($x['type'] === ACTIVITY_OBJ_EVENT) {
return self::fetch_event($x);
}
if($x['type'] === ACTIVITY_OBJ_PHOTO) {
return self::fetch_image($x);
if(array_key_exists('asld',$x)) {
return $x['asld'];
}

if($x['type'] === ACTIVITY_OBJ_PERSON) {
return self::fetch_person($x);
}
if($x['type'] === ACTIVITY_OBJ_PROFILE) {
return self::fetch_profile($x);
}
if(in_array($x['type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE ] )) {
return self::fetch_item($x);
}
if($x['type'] === ACTIVITY_OBJ_THING) {
return self::fetch_thing($x);
}
if($x['type'] === ACTIVITY_OBJ_EVENT) {
return self::fetch_event($x);
}
if($x['type'] === ACTIVITY_OBJ_PHOTO) {
return self::fetch_image($x);
}
}

return $x;
@@ -151,7 +156,7 @@ class Activity {
'type' => 'Image',
'id' => $x['id'],
'name' => $x['title'],
'content' => bbcode($x['body']),
'content' => bbcode($x['body'], [ 'cache' => true ]),
'source' => [ 'mediaType' => 'text/bbcode', 'content' => $x['body'] ],
'published' => datetime_convert('UTC','UTC',$x['created'],ATOM_TIME),
'updated' => datetime_convert('UTC','UTC', $x['edited'],ATOM_TIME),
@@ -181,14 +186,24 @@ class Activity {
$y = [
'type' => 'Event',
'id' => z_root() . '/event/' . $ev['event_hash'],
'summary' => bbcode($ev['summary']),
'summary' => bbcode($ev['summary'], [ 'cache' => true ]),
// RFC3339 Section 4.3
'startTime' => (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')),
'content' => bbcode($ev['description']),
'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location']) ],
'content' => bbcode($ev['description'], [ 'cache' => true ]),
'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location'], [ 'cache' => true ]) ],
'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ],
'actor' => $actor,
];
if(! $ev['nofinish']) {
$y['endTime'] = (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtend'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtend'],'Y-m-d\\TH:i:s-00:00'));
}
// copy attachments from the passed object - these are already formatted for ActivityStreams

if($x['attachment']) {
$y['attachment'] = $x['attachment'];
}

if($actor) {
return $y;
}
@@ -279,8 +294,12 @@ class Activity {
$ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME);
if($i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME);
if ($i['expires'] <= NULL_DATE) {
$ret['expires'] = datetime_convert('UTC','UTC',$i['expires'],ATOM_TIME);
}

if($i['app']) {
$ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ];
$ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
}
if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ];
@@ -297,15 +316,15 @@ class Activity {
$ret['attributedTo'] = $i['author']['xchan_url'];

if($i['id'] != $i['parent']) {
$ret['inReplyTo'] = ((strpos($i['parent_mid'],'http') === 0) ? $i['parent_mid'] : z_root() . '/item/' . urlencode($i['parent_mid']));
$ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent']));
}

if($i['mimetype'] === 'text/bbcode') {
if($i['title'])
$ret['name'] = bbcode($i['title']);
$ret['name'] = bbcode($i['title'], [ 'cache' => true ]);
if($i['summary'])
$ret['summary'] = bbcode($i['summary']);
$ret['content'] = bbcode($i['body']);
$ret['summary'] = bbcode($i['summary'], [ 'cache' => true ]);
$ret['content'] = bbcode($i['body'], [ 'cache' => true ]);
$ret['source'] = [ 'content' => $i['body'], 'mediaType' => 'text/bbcode' ];
}

@@ -398,7 +417,7 @@ class Activity {
$ret = [];

if($item['attach']) {
$atts = json_decode($item['attach'],true);
$atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'],true));
if($atts) {
foreach($atts as $att) {
if(strpos($att['type'],'image')) {
@@ -410,7 +429,7 @@ class Activity {
}
}
}
return $ret;
}

@@ -457,20 +476,26 @@ class Activity {
return $ret;
}

if($i['verb'] === ACTIVITY_FRIEND) {
// Hubzilla 'make-friend' activity, no direct mapping from AS1 to AS2 - make it a note
$ret['obj_type'] = ACTIVITY_OBJ_NOTE;
$ret['obj'] = [];
}

$ret['type'] = self::activity_mapper($i['verb']);


$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid']));

if($i['title'])
$ret['name'] = html2plain(bbcode($i['title']));
$ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ]));

if($i['summary'])
$ret['summary'] = bbcode($i['summary']);
$ret['summary'] = bbcode($i['summary'], [ 'cache' => true ]);

if($ret['type'] === 'Announce') {
$tmp = preg_replace('/\[share(.*?)\[\/share\]/ism',EMPTY_STR, $i['body']);
$ret['content'] = bbcode($tmp);
$ret['content'] = bbcode($tmp, [ 'cache' => true ]);
$ret['source'] = [
'content' => $i['body'],
'mediaType' => 'text/bbcode'
@@ -481,7 +506,7 @@ class Activity {
if($i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME);
if($i['app']) {
$ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ];
$ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
}
if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ];
@@ -496,7 +521,7 @@ class Activity {
}

if($i['id'] != $i['parent']) {
$ret['inReplyTo'] = ((strpos($i['parent_mid'],'http') === 0) ? $i['parent_mid'] : z_root() . '/item/' . urlencode($i['parent_mid']));
$ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent']));
$reply = true;

if($i['item_private']) {
@@ -553,6 +578,7 @@ class Activity {
return [];
}


if($i['target']) {
if(! is_array($i['target'])) {
$i['target'] = json_decode($i['target'],true);
@@ -697,7 +723,7 @@ class Activity {
// Reactions will just map to normal activities

if(strpos($verb,ACTIVITY_REACT) !== false)
return 'Create';
return 'emojiReaction';
if(strpos($verb,ACTIVITY_MOOD) !== false)
return 'Create';

@@ -1287,6 +1313,12 @@ class Activity {
elseif($act->obj['updated']) {
$s['edited'] = datetime_convert('UTC','UTC',$act->obj['updated']);
}
if ($act->data['expires']) {
$s['expires'] = datetime_convert('UTC','UTC',$act->data['expires']);
}
elseif ($act->obj['expires']) {
$s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
}

if(! $s['created'])
$s['created'] = datetime_convert();
@@ -1305,13 +1337,13 @@ class Activity {
$s['verb'] = ACTIVITY_POST;
$s['obj_type'] = ACTIVITY_OBJ_NOTE;

$instrument = $act->get_property_obj('instrument');
if(! $instrument)
$instrument = $act->get_property_obj('instrument',$act->obj);
$generator = $act->get_property_obj('generator');
if(! $generator)
$generator = $act->get_property_obj('generator',$act->obj);

if($instrument && array_key_exists('type',$instrument)
&& $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) {
$s['app'] = escape_tags($instrument['name']);
if($generator && array_key_exists('type',$generator)
&& in_array($generator['type'], [ 'Application','Service' ] ) && array_key_exists('name',$generator)) {
$s['app'] = escape_tags($generator['name']);
}

if($channel['channel_system']) {
@@ -1471,9 +1503,15 @@ class Activity {
elseif($act->obj['updated']) {
$s['edited'] = datetime_convert('UTC','UTC',$act->obj['updated']);
}
if ($act->data['expires']) {
$s['expires'] = datetime_convert('UTC','UTC',$act->data['expires']);
}
elseif ($act->obj['expires']) {
$s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
}


if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept' ])) {
if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) {

$response_activity = true;

@@ -1514,6 +1552,9 @@ class Activity {
if($act->type === 'Announce') {
$content['content'] = sprintf( t('&#x1f501; Repeated %1$s\'s %2$s'), $mention, $act->obj['type']);
}
if ($act->type === 'emojiReaction') {
$content['content'] = (($act->tgt && $act->tgt['type'] === 'Image') ? '[img=32x32]' . $act->tgt['url'] . '[/img]' : '&#x' . $act->tgt['name'] . ';');
}
}

if(! $s['created'])
@@ -1565,14 +1606,14 @@ class Activity {
$s['obj'] = $act->obj;
}

$instrument = $act->get_property_obj('instrument');
if((! $instrument) && (! $response_activity)) {
$instrument = $act->get_property_obj('instrument',$act->obj);
$generator = $act->get_property_obj('generator');
if((! $generator) && (! $response_activity)) {
$generator = $act->get_property_obj('generator',$act->obj);
}

if($instrument && array_key_exists('type',$instrument)
&& $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) {
$s['app'] = escape_tags($instrument['name']);
if($generator && array_key_exists('type',$generator)
&& in_array($generator['type'], [ 'Application', 'Service' ] ) && array_key_exists('name',$generator)) {
$s['app'] = escape_tags($generator['name']);
}




+ 2
- 3
Zotlabs/Lib/Apps.php View File

@@ -70,7 +70,7 @@ class Apps {
'Channel Home',
'View Profile',
'Photos',
'Events',
'Calendar',
'Directory',
'Search',
'Help',
@@ -342,7 +342,7 @@ class Apps {
'Channel Home' => t('Channel Home'),
'View Profile' => t('View Profile'),
'Photos' => t('Photos'),
'Events' => t('Events'),
'Calendar' => t('Calendar'),
'Directory' => t('Directory'),
'Help' => t('Help'),
'Mail' => t('Mail'),
@@ -363,7 +363,6 @@ class Apps {
'Privacy Groups' => t('Privacy Groups'),
'Notifications' => t('Notifications'),
'Order Apps' => t('Order Apps'),
'CalDAV' => t('CalDAV'),
'CardDAV' => t('CardDAV'),
'Channel Sources' => t('Channel Sources'),
'Guest Access' => t('Guest Access'),


+ 8
- 1
Zotlabs/Lib/DB_Upgrade.php View File

@@ -58,10 +58,15 @@ class DB_Upgrade {

$c = new $cls();

$retval = $c->run();

if($retval != UPDATE_SUCCESS) {


$source = t('Source code of failed update: ') . "\n\n" . @file_get_contents('Zotlabs/Update/' . $s . '.php');

// Prevent sending hundreds of thousands of emails by creating
// a lockfile.

@@ -86,7 +91,9 @@ class DB_Upgrade {
'$sitename' => \App::$config['system']['sitename'],
'$siteurl' => z_root(),
'$update' => $x,
'$error' => sprintf( t('Update %s failed. See error logs.'), $x)
'$error' => sprintf( t('Update %s failed. See error logs.'), $x),
'$baseurl' => z_root(),
'$source' => $source
]
)
]


+ 1
- 1
Zotlabs/Lib/Libzot.php View File

@@ -2766,7 +2766,7 @@ class Libzot {

$profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob'];
if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== ''))
if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],'UTC')) !== ''))
$profile['next_birthday'] = $bd;

if($age = age($p[0]['dob'],$e['channel_timezone'],''))


+ 13
- 13
Zotlabs/Lib/ThreadItem.php View File

@@ -38,6 +38,7 @@ class ThreadItem {
$this->data = $data;
$this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
$this->threaded = get_config('system','thread_allow');

$observer = \App::get_observer();

@@ -305,6 +306,7 @@ class ThreadItem {
if($this->is_commentable() && $observer) {
$like = array( t("I like this \x28toggle\x29"), t("like"));
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
$reply_to = array( t("Reply on this comment"), t("reply"), t("Reply to"));
}

if ($shareable) {
@@ -331,7 +333,6 @@ class ThreadItem {
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$is_new = true;


localize_item($item);

$body = prepare_body($item,true);
@@ -347,10 +348,6 @@ class ThreadItem {
$comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
$list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : '');


$children = $this->get_children();

$has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false);
@@ -373,13 +370,15 @@ class ThreadItem {
'text' => strip_tags($body['html']),
'id' => $this->get_id(),
'mid' => $item['mid'],
'parent' => $item['parent'],
'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']),
'isevent' => $isevent,
'attend' => $attend,
'consensus' => $consensus,
'conlabels' => $conlabels,
'canvote' => $canvote,
'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']),
'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']),
'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url'])),
'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url'])),
'llink' => $item['llink'],
'viewthread' => $viewthread,
'to' => t('to'),
@@ -425,9 +424,11 @@ class ThreadItem {
'has_tags' => $has_tags,
'reactions' => $this->reactions,
// Item toolbar buttons
'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''),
'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''),
'like' => $like,
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''),
'reply_to' => (((! $this->is_toplevel()) && feature_enabled($conv->get_profile_owner(),'reply_to')) ? $reply_to : ''),
'top_hint' => t("Go to previous comment"),
'share' => $share,
'embed' => $embed,
'rawmid' => $item['mid'],
@@ -440,9 +441,8 @@ class ThreadItem {
'addtocal' => (($has_event) ? t('Add to Calendar') : ''),
'drop' => $drop,
'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''),
'dropdown_extras' => $dropdown_extras,
'dropdown_extras' => $dropdown_extras,
// end toolbar buttons

'unseen_comments' => $unseen_comments,
'comment_count' => $total_children,
'comment_count_txt' => $comment_count_txt,
@@ -469,7 +469,8 @@ class ThreadItem {
'wait' => t('Please wait'),
'submid' => str_replace(['+','='], ['',''], base64_encode($item['mid'])),
'thread_level' => $thread_level,
'settings' => $settings
'settings' => $settings,
'thr_parent' => (($item['parent_mid'] != $item['thr_parent']) ? $item['thr_parent'] : '')
);

$arr = array('item' => $item, 'output' => $tmp_item);
@@ -814,7 +815,7 @@ class ThreadItem {
'$anonname' => [ 'anonname', t('Your full name (required)') ],
'$anonmail' => [ 'anonmail', t('Your email address (required)') ],
'$anonurl' => [ 'anonurl', t('Your website URL (optional)') ],
'$auto_save_draft' => $feature_auto_save_draft,
'$auto_save_draft' => $feature_auto_save_draft
));

return $comment_box;
@@ -869,4 +870,3 @@ class ThreadItem {


}


+ 43
- 2
Zotlabs/Module/Admin/Dbsync.php View File

@@ -19,7 +19,47 @@ class Dbsync {
info( t('Update has been marked successful') . EOL);
goaway(z_root() . '/admin/dbsync');
}

if(argc() > 3 && intval(argv(3)) && argv(2) === 'verify') {

$s = '_' . intval(argv(3));
$cls = '\\Zotlabs\Update\\' . $s ;
if(class_exists($cls)) {
$c = new $cls();
if(method_exists($c,'verify')) {
$retval = $c->verify();
if($retval === UPDATE_FAILED) {
$o .= sprintf( t('Verification of update %s failed. Check system logs.'), $s);
}
elseif($retval === UPDATE_SUCCESS) {
$o .= sprintf( t('Update %s was successfully applied.'), $s);
set_config('database',$s, 'success');
}
else
$o .= sprintf( t('Verifying update %s did not return a status. Unknown if it succeeded.'), $s);
}
else {
$o .= sprintf( t('Update %s does not contain a verification function.'), $s );
}
}
else
$o .= sprintf( t('Update function %s could not be found.'), $s);
return $o;





// remove the old style config if it exists
del_config('database', 'update_r' . intval(argv(3)));
set_config('database', '_' . intval(argv(3)), 'success');
if(intval(get_config('system','db_version')) < intval(argv(3)))
set_config('system','db_version',intval(argv(3)));
info( t('Update has been marked successful') . EOL);
goaway(z_root() . '/admin/dbsync');
}

if(argc() > 2 && intval(argv(2))) {
$x = intval(argv(2));
$s = '_' . $x;
@@ -28,14 +68,14 @@ class Dbsync {
$c = new $cls();
$retval = $c->run();
if($retval === UPDATE_FAILED) {
$o .= sprintf( t('Executing %s failed. Check system logs.'), $s);
$o .= sprintf( t('Executing update procedure %s failed. Check system logs.'), $s);
}
elseif($retval === UPDATE_SUCCESS) {
$o .= sprintf( t('Update %s was successfully applied.'), $s);
set_config('database',$s, 'success');
}
else
$o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $s);
$o .= sprintf( t('Update %s did not return a status. It cannot be determined if it was successful.'), $s);
}
else
$o .= sprintf( t('Update function %s could not be found.'), $s);
@@ -59,6 +99,7 @@ class Dbsync {
'$banner' => t('Failed Updates'),
'$desc' => '',
'$mark' => t('Mark success (if update was manually applied)'),
'$verify' => t('Attempt to verify this update if a verification procedure exists'),
'$apply' => t('Attempt to execute this update step automatically'),
'$failed' => $failed
));


+ 57
- 0
Zotlabs/Module/Apschema.php View File

@@ -0,0 +1,57 @@
<?php

namespace Zotlabs\Module;


class Apschema extends \Zotlabs\Web\Controller {

function init() {

$base = z_root();

$arr = [
'@context' => [
'zot' => z_root() . '/apschema#',
'id' => '@id',
'type' => '@type',
'commentPolicy' => 'as:commentPolicy',
'meData' => 'zot:meData',
'meDataType' => 'zot:meDataType',
'meEncoding' => 'zot:meEncoding',
'meAlgorithm' => 'zot:meAlgorithm',
'meCreator' => 'zot:meCreator',
'meSignatureValue' => 'zot:meSignatureValue',
'locationAddress' => 'zot:locationAddress',
'locationPrimary' => 'zot:locationPrimary',
'locationDeleted' => 'zot:locationDeleted',
'nomadicLocation' => 'zot:nomadicLocation',
'nomadicHubs' => 'zot:nomadicHubs',
'emojiReaction' => 'zot:emojiReaction',
'expires' => 'zot:expires',
'magicEnv' => [
'@id' => 'zot:magicEnv',
'@type' => '@id'
],

'nomadicLocations' => [
'@id' => 'zot:nomadicLocations',
'@type' => '@id'
],

'ostatus' => 'http://ostatus.org#',
'conversation' => 'ostatus:conversation'

]
];

header('Content-Type: application/ld+json');
echo json_encode($arr,JSON_UNESCAPED_SLASHES);
killme();

}




}

+ 22
- 14
Zotlabs/Module/Cal.php View File

@@ -84,6 +84,7 @@ class Cal extends \Zotlabs\Web\Controller {
'$module_url' => '/cal/' . $channel['channel_address'],
'$modparams' => 2,
'$lang' => \App::$language,
'$timezone' => date_default_timezone_get(),
'$first_day' => $first_day
));
@@ -215,8 +216,8 @@ class Cal extends \Zotlabs\Web\Controller {
$sql_extra .= " and etype != 'birthday' ";

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 $sql_extra limit 1",
$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 resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
intval($channel['channel_id']),
intval($_GET['id'])
);
@@ -227,12 +228,12 @@ class Cal extends \Zotlabs\Web\Controller {
// 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
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' )) $sql_extra ",
intval($channel['channel_id']),
$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.event_hash = item.resource_id
where item.resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored
AND (( event.adjust = 0 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )
OR ( event.adjust = 1 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )) ",
intval(local_channel()),
dbesc($start),
dbesc($finish),
dbesc($adjust_start),
@@ -266,16 +267,23 @@ class Cal extends \Zotlabs\Web\Controller {
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));

$tz = get_iconfig($rr, 'event', 'timezone');

if(! $tz)
$tz = 'UTC';

$rr['timezone'] = $tz;

$j = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
$d = (($rr['adjust']) ? datetime_convert($tz,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'));
$start = (($rr['adjust']) ? datetime_convert($tz,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'));
$end = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c'));
}
@@ -302,7 +310,7 @@ class Cal extends \Zotlabs\Web\Controller {
'start'=> $start,
'end' => $end,
'drop' => $drop,
'allDay' => false,
'allDay' => (($rr['adjust']) ? 0 : 1),
'title' => $title,
'j' => $j,


+ 184
- 51
Zotlabs/Module/Cdav.php View File

@@ -133,10 +133,6 @@ class Cdav extends Controller {

logger('loggedin');

if((argv(1) == 'calendars') && (!Apps::system_app_installed(local_channel(), 'CalDAV'))) {
killme();
}

if((argv(1) == 'addressbooks') && (!Apps::system_app_installed(local_channel(), 'CardDAV'))) {
killme();
}
@@ -221,10 +217,6 @@ class Cdav extends Controller {
if(! local_channel())
return;

if((argv(1) === 'calendar') && (! Apps::system_app_installed(local_channel(), 'CalDAV'))) {
return;
}

if((argv(1) === 'addressbook') && (! Apps::system_app_installed(local_channel(), 'CardDAV'))) {
return;
}
@@ -279,11 +271,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;

$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());

$allday = $_REQUEST['allday'];

$title = $_REQUEST['title'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);

if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
$end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}
$description = $_REQUEST['description'];
@@ -309,16 +307,23 @@ class Cdav extends Controller {
'DTSTART' => $dtstart
]
]);

if($dtend) {
$vcalendar->VEVENT->add('DTEND', $dtend);
$vcalendar->VEVENT->DTEND['TZID'] = App::$timezone;
if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
if($description)
$vcalendar->VEVENT->add('DESCRIPTION', $description);
if($location)
$vcalendar->VEVENT->add('LOCATION', $location);

$vcalendar->VEVENT->DTSTART['TZID'] = App::$timezone;
if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;

$calendarData = $vcalendar->serialize();

@@ -356,12 +361,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;

$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());

$allday = $_REQUEST['allday'];

$uri = $_REQUEST['uri'];
$title = $_REQUEST['title'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
$end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}
$description = $_REQUEST['description'];
@@ -373,12 +383,23 @@ class Cdav extends Controller {

if($title)
$vcalendar->VEVENT->SUMMARY = $title;
if($dtstart)
if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
if($dtend)
if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;
}
if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
else
unset($vcalendar->VEVENT->DTEND);

if($description)
$vcalendar->VEVENT->DESCRIPTION = $description;
if($location)
@@ -414,11 +435,16 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;

$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());

$allday = $_REQUEST['allday'];

$uri = $_REQUEST['uri'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
$start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
$end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}

@@ -428,13 +454,20 @@ class Cdav extends Controller {

if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;
}
if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
else {
else
unset($vcalendar->VEVENT->DTEND);
}

$calendarData = $vcalendar->serialize();

@@ -762,16 +795,27 @@ class Cdav extends Controller {
//Import calendar or addressbook
if(($_FILES) && array_key_exists('userfile',$_FILES) && intval($_FILES['userfile']['size']) && $_REQUEST['target']) {

$src = @file_get_contents($_FILES['userfile']['tmp_name']);
$src = $_FILES['userfile']['tmp_name'];

if($src) {

if($_REQUEST['c_upload']) {
if($_REQUEST['target'] == 'channel_calendar') {
$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);
return;
}

$id = explode(':', $_REQUEST['target']);
$ext = 'ics';
$table = 'calendarobjects';
$column = 'calendarid';
$objects = new \Sabre\VObject\Splitter\ICalendar($src);
$objects = new \Sabre\VObject\Splitter\ICalendar(@file_get_contents($src));
$profile = \Sabre\VObject\Node::PROFILE_CALDAV;
$backend = new \Sabre\CalDAV\Backend\PDO($pdo);
}
@@ -781,7 +825,7 @@ class Cdav extends Controller {
$ext = 'vcf';
$table = 'cards';
$column = 'addressbookid';
$objects = new \Sabre\VObject\Splitter\VCard($src);
$objects = new \Sabre\VObject\Splitter\VCard(@file_get_contents($src));
$profile = \Sabre\VObject\Node::PROFILE_CARDDAV;
$backend = new \Sabre\CardDAV\Backend\PDO($pdo);
}
@@ -847,15 +891,6 @@ class Cdav extends Controller {
if(!local_channel())
return;

if((argv(1) === 'calendar') && (! Apps::system_app_installed(local_channel(), 'CalDAV'))) {
//Do not display any associated widgets at this point
App::$pdl = '';

$o = '<b>' . t('CalDAV App') . ' (' . t('Not Installed') . '):</b><br>';
$o .= t('CalDAV capable calendar');
return $o;
}

if((argv(1) === 'addressbook') && (! Apps::system_app_installed(local_channel(), 'CardDAV'))) {
//Do not display any associated widgets at this point
App::$pdl = '';
@@ -884,13 +919,13 @@ class Cdav extends Controller {
}

if(argv(1) === 'calendar') {
nav_set_selected('CalDAV');
nav_set_selected('Calendar');
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);