aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r--Zotlabs/Widget/Cdav.php176
-rw-r--r--Zotlabs/Widget/Conversations.php8
-rw-r--r--Zotlabs/Widget/Settings_menu.php12
-rw-r--r--Zotlabs/Widget/Tasklist.php4
4 files changed, 188 insertions, 12 deletions
diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php
new file mode 100644
index 000000000..1b33668ad
--- /dev/null
+++ b/Zotlabs/Widget/Cdav.php
@@ -0,0 +1,176 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+
+
+class Cdav {
+
+ function widget() {
+ if(!local_channel())
+ return;
+
+ $channel = \App::get_channel();
+ $principalUri = 'principals/' . $channel['channel_hash'];
+
+ if(!cdav_principal($principalUri))
+ return;
+
+ $pdo = \DBA::$dba->db;
+
+ require_once 'vendor/autoload.php';
+
+ $o = '';
+
+ if(argc() == 2 && argv(1) === 'calendar') {
+
+ $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
+
+ $sabrecals = $caldavBackend->getCalendarsForUser($principalUri);
+
+ //TODO: we should probably also check for permission to send stream here
+ $local_channels = q("SELECT * FROM channel LEFT JOIN abook ON abook_xchan = channel_hash WHERE channel_system = 0 AND channel_removed = 0 AND channel_hash != '%s' AND abook_channel = %d",
+ dbesc($channel['channel_hash']),
+ intval($channel['channel_id'])
+ );
+
+ $sharee_options .= '<option value="">' . t('Select Channel') . '</option>' . "\r\n";
+ foreach($local_channels as $local_channel) {
+ $sharee_options .= '<option value="' . $local_channel['channel_hash'] . '">' . $local_channel['channel_name'] . '</option>' . "\r\n";
+ }
+
+ $access_options = '<option value="3">' . t('Read-write') . '</option>' . "\r\n";
+ $access_options .= '<option value="2">' . t('Read-only') . '</option>' . "\r\n";
+
+ //list calendars
+ foreach($sabrecals as $sabrecal) {
+ if($sabrecal['share-access'] == 1)
+ $access = '';
+ if($sabrecal['share-access'] == 2)
+ $access = 'read';
+ if($sabrecal['share-access'] == 3)
+ $access = 'read-write';
+
+ $invites = $caldavBackend->getInvites($sabrecal['id']);
+
+ $json_source = '/cdav/calendar/json/' . $sabrecal['id'][0] . '/' . $sabrecal['id'][1];
+
+ $switch = get_pconfig(local_channel(), 'cdav_calendar', $sabrecal['id'][0]);
+
+ $color = (($sabrecal['{http://apple.com/ns/ical/}calendar-color']) ? $sabrecal['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad');
+
+ $editable = (($sabrecal['share-access'] == 2) ? 'false' : 'true'); // false/true must be string since we're passing it to javascript
+
+ $sharees = [];
+ $share_displayname = [];
+ foreach($invites as $invite) {
+ if(strpos($invite->href, 'mailto:') !== false) {
+ $sharee = channelx_by_hash(substr($invite->href, 7));
+ $sharees[] = [
+ 'name' => $sharee['channel_name'],
+ 'access' => (($invite->access == 3) ? ' (RW)' : ' (R)'),
+ 'hash' => $sharee['channel_hash']
+ ];
+ }
+ }
+
+ if(!$access) {
+ $my_calendars[] = [
+ 'ownernick' => $channel['channel_address'],
+ 'uri' => $sabrecal['uri'],
+ 'displayname' => $sabrecal['{DAV:}displayname'],
+ 'calendarid' => $sabrecal['id'][0],
+ 'instanceid' => $sabrecal['id'][1],
+ 'json_source' => $json_source,
+ 'color' => $color,
+ 'editable' => $editable,
+ 'switch' => $switch,
+ 'sharees' => $sharees
+ ];
+ }
+ else {
+ $shared_calendars[] = [
+ 'ownernick' => $channel['channel_address'],
+ 'uri' => $sabrecal['uri'],
+ 'displayname' => $sabrecal['{DAV:}displayname'],
+ 'calendarid' => $sabrecal['id'][0],
+ 'instanceid' => $sabrecal['id'][1],
+ 'json_source' => $json_source,
+ 'color' => $color,
+ 'editable' => $editable,
+ 'switch' => $switch,
+ 'sharer' => $sabrecal['{urn:ietf:params:xml:ns:caldav}calendar-description'],
+ 'access' => $access
+ ];
+ }
+
+ if(!$access || $access === 'read-write') {
+ $writable_calendars[] = [
+ 'displayname' => ((!$access) ? $sabrecal['{DAV:}displayname'] : $share_displayname[0]),
+ 'id' => $sabrecal['id']
+ ];
+ }
+ }
+
+ $o .= replace_macros(get_markup_template('cdav_widget_calendar.tpl'), [
+ '$my_calendars_label' => t('My Calendars'),
+ '$my_calendars' => $my_calendars,
+ '$shared_calendars_label' => t('Shared Calendars'),
+ '$shared_calendars' => $shared_calendars,
+ '$sharee_options' => $sharee_options,
+ '$access_options' => $access_options,
+ '$share_label' => t('Share this calendar'),
+ '$share' => t('Share'),
+ '$edit_label' => t('Calendar name and color'),
+ '$edit' => t('Edit'),
+ '$create_label' => t('Create new calendar'),
+ '$create' => t('Create'),
+ '$create_placeholder' => t('Calendar Name'),
+ '$tools_label' => t('Calendar Tools'),
+ '$import_label' => t('Import calendar'),
+ '$import_placeholder' => t('Select a calendar to import to'),
+ '$upload' => t('Upload'),
+ '$writable_calendars' => $writable_calendars
+ ]);
+
+ return $o;
+
+ }
+
+ if(argc() >= 2 && argv(1) === 'addressbook') {
+
+ $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
+
+ $sabreabooks = $carddavBackend->getAddressBooksForUser($principalUri);
+
+ //list addressbooks
+ foreach($sabreabooks as $sabreabook) {
+ $addressbooks[] = [
+ 'ownernick' => $channel['channel_address'],
+ 'uri' => $sabreabook['uri'],
+ 'displayname' => $sabreabook['{DAV:}displayname'],
+ 'id' => $sabreabook['id']
+
+ ];
+ }
+
+ $o .= replace_macros(get_markup_template('cdav_widget_addressbook.tpl'), [
+ '$addressbooks_label' => t('Addressbooks'),
+ '$addressbooks' => $addressbooks,
+ '$edit_label' => t('Addressbook name'),
+ '$edit' => t('Edit'),
+ '$create_label' => t('Create new addressbook'),
+ '$create_placeholder' => t('Addressbook Name'),
+ '$create' => t('Create'),
+ '$tools_label' => t('Addressbook Tools'),
+ '$import_label' => t('Import addressbook'),
+ '$import_placeholder' => t('Select an addressbook to import to'),
+ '$upload' => t('Upload')
+ ]);
+
+ return $o;
+
+ }
+
+ }
+} \ No newline at end of file
diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php
index 27e517c02..4fd754f66 100644
--- a/Zotlabs/Widget/Conversations.php
+++ b/Zotlabs/Widget/Conversations.php
@@ -12,10 +12,6 @@ class Conversations {
if(argc() > 1) {
switch(argv(1)) {
- case 'combined':
- $mailbox = 'combined';
- $header = t('Conversations');
- break;
case 'inbox':
$mailbox = 'inbox';
$header = t('Received Messages');
@@ -58,7 +54,7 @@ class Conversations {
'body' => $rr['body'],
'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'),
'seen' => $rr['seen'],
- 'selected' => ((argv(2)) ? (argv(2) == $rr['id']) : ($r[0]['id'] == $rr['id']))
+ 'selected' => ((argc() == 2) ? (intval(argv(1)) == intval($rr['id'])) : ($r[0]['id'] == $rr['id']))
);
}
@@ -71,4 +67,6 @@ class Conversations {
}
return $o;
}
+
}
+
diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php
index 753390c23..c15ad0980 100644
--- a/Zotlabs/Widget/Settings_menu.php
+++ b/Zotlabs/Widget/Settings_menu.php
@@ -79,11 +79,13 @@ class Settings_menu {
'selected' => ''
);
- $tabs[] = array(
- 'label' => t('Connected apps'),
- 'url' => z_root() . '/settings/oauth',
- 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
- );
+ if(get_account_techlevel() > 0) {
+ $tabs[] = array(
+ 'label' => t('Connected apps'),
+ 'url' => z_root() . '/settings/oauth',
+ 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
+ );
+ }
if(get_account_techlevel() > 2) {
$tabs[] = array(
diff --git a/Zotlabs/Widget/Tasklist.php b/Zotlabs/Widget/Tasklist.php
index 6f7a8aaed..3961eecce 100644
--- a/Zotlabs/Widget/Tasklist.php
+++ b/Zotlabs/Widget/Tasklist.php
@@ -8,8 +8,8 @@ class Tasklist {
function widget($arr) {
- if (! local_channel())
- return;
+ if (! local_channel())
+ return;
$o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';
$o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id, function(data) { tasksFetch();}); }