aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 20:56:12 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 11:50:52 +0200
commit6e101e458268c0f9b7bf461cea3c31c37b5e3791 (patch)
tree2a641a76607431a2661b0d3b6c46babbd34b6c0d /Zotlabs/Widget
parentf60309efa12be3b8d4f5b2c565ebdf7f051a987d (diff)
downloadvolse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.tar.gz
volse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.tar.bz2
volse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.zip
widgets cont.
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r--Zotlabs/Widget/Affinity.php60
-rw-r--r--Zotlabs/Widget/Catcloud_wall.php19
-rw-r--r--Zotlabs/Widget/Conversations.php74
-rw-r--r--Zotlabs/Widget/Design_tools.php21
-rw-r--r--Zotlabs/Widget/Eventstools.php19
-rw-r--r--Zotlabs/Widget/Mailmenu.php36
-rw-r--r--Zotlabs/Widget/Photo_albums.php25
-rw-r--r--Zotlabs/Widget/Settings_menu.php137
-rw-r--r--Zotlabs/Widget/Tagcloud_wall.php20
9 files changed, 411 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php
new file mode 100644
index 000000000..439ba1f33
--- /dev/null
+++ b/Zotlabs/Widget/Affinity.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Affinity {
+
+ function widget($arr) {
+
+ if(! local_channel())
+ return '';
+
+ // Get default cmin value from pconfig, but allow GET parameter to override
+ $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
+ $cmin = (($cmin) ? $cmin : 0);
+ $cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $cmin);
+
+ // Get default cmax value from pconfig, but allow GET parameter to override
+ $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
+ $cmax = (($cmax) ? $cmax : 99);
+ $cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $cmax);
+
+
+ if(feature_enabled(local_channel(),'affinity')) {
+
+ $labels = array(
+ t('Me'),
+ t('Family'),
+ t('Friends'),
+ t('Acquaintances'),
+ t('All')
+ );
+ call_hooks('affinity_labels',$labels);
+ $label_str = '';
+
+ if($labels) {
+ foreach($labels as $l) {
+ if($label_str) {
+ $label_str .= ", '|'";
+ $label_str .= ", '" . $l . "'";
+ }
+ else
+ $label_str .= "'" . $l . "'";
+ }
+ }
+
+ $tpl = get_markup_template('main_slider.tpl');
+ $x = replace_macros($tpl,array(
+ '$val' => $cmin . ',' . $cmax,
+ '$refresh' => t('Refresh'),
+ '$labels' => $label_str,
+ ));
+
+ $arr = array('html' => $x);
+ call_hooks('main_slider',$arr);
+ return $arr['html'];
+ }
+ return '';
+ }
+}
+ \ No newline at end of file
diff --git a/Zotlabs/Widget/Catcloud_wall.php b/Zotlabs/Widget/Catcloud_wall.php
new file mode 100644
index 000000000..3795987cc
--- /dev/null
+++ b/Zotlabs/Widget/Catcloud_wall.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Catcloud_wall {
+
+ function widget($arr) {
+
+ if((! \App::$profile['profile_uid']) || (! \App::$profile['channel_hash']))
+ return '';
+ if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_stream'))
+ return '';
+
+ $limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50);
+
+ return catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash'], 'wall');
+ }
+
+}
diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php
new file mode 100644
index 000000000..fa59ce20c
--- /dev/null
+++ b/Zotlabs/Widget/Conversations.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Conversations {
+
+ function widget($arr) {
+
+ if (! local_channel())
+ return;
+
+ if(argc() > 1) {
+
+ switch(argv(1)) {
+ case 'combined':
+ $mailbox = 'combined';
+ $header = t('Conversations');
+ break;
+ case 'inbox':
+ $mailbox = 'inbox';
+ $header = t('Received Messages');
+ break;
+ case 'outbox':
+ $mailbox = 'outbox';
+ $header = t('Sent Messages');
+ break;
+ default:
+ $mailbox = 'combined';
+ $header = t('Conversations');
+ break;
+ }
+
+ require_once('include/message.php');
+
+ // private_messages_list() can do other more complicated stuff, for now keep it simple
+ $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']);
+
+ if(! $r) {
+ info( t('No messages.') . EOL);
+ return $o;
+ }
+
+ $messages = array();
+
+ foreach($r as $rr) {
+
+ $messages[] = array(
+ 'mailbox' => $mailbox,
+ 'id' => $rr['id'],
+ 'from_name' => $rr['from']['xchan_name'],
+ 'from_url' => chanlink_hash($rr['from_xchan']),
+ 'from_photo' => $rr['from']['xchan_photo_s'],
+ 'to_name' => $rr['to']['xchan_name'],
+ 'to_url' => chanlink_hash($rr['to_xchan']),
+ 'to_photo' => $rr['to']['xchan_photo_s'],
+ 'subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'),
+ 'delete' => t('Delete conversation'),
+ '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']))
+ );
+ }
+
+ $tpl = get_markup_template('mail_head.tpl');
+ $o .= replace_macros($tpl, array(
+ '$header' => $header,
+ '$messages' => $messages
+ ));
+
+ }
+ return $o;
+ }
+} \ No newline at end of file
diff --git a/Zotlabs/Widget/Design_tools.php b/Zotlabs/Widget/Design_tools.php
new file mode 100644
index 000000000..8ab6a235d
--- /dev/null
+++ b/Zotlabs/Widget/Design_tools.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Design_tools {
+
+ function widget($arr) {
+
+ // mod menu doesn't load a profile. For any modules which load a profile, check it.
+ // otherwise local_channel() is sufficient for permissions.
+
+ if(\App::$profile['profile_uid'])
+ if((\App::$profile['profile_uid'] != local_channel()) && (! \App::$is_sys))
+ return '';
+
+ if(! local_channel())
+ return '';
+
+ return design_tools();
+ }
+} \ No newline at end of file
diff --git a/Zotlabs/Widget/Eventstools.php b/Zotlabs/Widget/Eventstools.php
new file mode 100644
index 000000000..7efd3f72e
--- /dev/null
+++ b/Zotlabs/Widget/Eventstools.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Eventstools {
+
+ function widget($arr) {
+
+ if(! local_channel())
+ return;
+
+ return replace_macros(get_markup_template('events_tools_side.tpl'), array(
+ '$title' => t('Events Tools'),
+ '$export' => t('Export Calendar'),
+ '$import' => t('Import Calendar'),
+ '$submit' => t('Submit')
+ ));
+ }
+}
diff --git a/Zotlabs/Widget/Mailmenu.php b/Zotlabs/Widget/Mailmenu.php
new file mode 100644
index 000000000..512f7d9c0
--- /dev/null
+++ b/Zotlabs/Widget/Mailmenu.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Mailmenu {
+
+ function widget($arr) {
+
+ if (! local_channel())
+ return;
+
+ return replace_macros(get_markup_template('message_side.tpl'), array(
+ '$title' => t('Private Mail Menu'),
+ '$combined' => array(
+ 'label' => t('Combined View'),
+ 'url' => z_root() . '/mail/combined',
+ 'sel' => (argv(1) == 'combined'),
+ ),
+ '$inbox' => array(
+ 'label' => t('Inbox'),
+ 'url' => z_root() . '/mail/inbox',
+ 'sel' => (argv(1) == 'inbox'),
+ ),
+ '$outbox' => array(
+ 'label' => t('Outbox'),
+ 'url' => z_root() . '/mail/outbox',
+ 'sel' => (argv(1) == 'outbox'),
+ ),
+ '$new' => array(
+ 'label' => t('New Message'),
+ 'url' => z_root() . '/mail/new',
+ 'sel'=> (argv(1) == 'new'),
+ )
+ ));
+ }
+}
diff --git a/Zotlabs/Widget/Photo_albums.php b/Zotlabs/Widget/Photo_albums.php
new file mode 100644
index 000000000..2a746e492
--- /dev/null
+++ b/Zotlabs/Widget/Photo_albums.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+require_once('include/photos.php');
+
+class Photo_albums {
+
+ function widget($arr) {
+
+ if(! \App::$profile['profile_uid'])
+ return '';
+
+ $channelx = channelx_by_n(\App::$profile['profile_uid']);
+
+ if((! $channelx) || (! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_storage')))
+ return '';
+
+ $sortkey = ((array_key_exists('sortkey',$arr)) ? $arr['sortkey'] : 'album');
+ $direction = ((array_key_exists('direction',$arr)) ? $arr['direction'] : 'asc');
+
+ return photos_album_widget($channelx, \App::get_observer(),$sortkey,$direction);
+ }
+}
+
diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php
new file mode 100644
index 000000000..753390c23
--- /dev/null
+++ b/Zotlabs/Widget/Settings_menu.php
@@ -0,0 +1,137 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Settings_menu {
+
+ function widget($arr) {
+
+ if(! local_channel())
+ return;
+
+
+ $channel = \App::get_channel();
+
+ $abook_self_id = 0;
+
+ // Retrieve the 'self' address book entry for use in the auto-permissions link
+
+ $role = get_pconfig(local_channel(),'system','permissions_role');
+
+ $abk = q("select abook_id from abook where abook_channel = %d and abook_self = 1 limit 1",
+ intval(local_channel())
+ );
+ if($abk)
+ $abook_self_id = $abk[0]['abook_id'];
+
+ $x = q("select count(*) as total from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 ",
+ dbesc($channel['channel_hash'])
+ );
+
+ $hublocs = (($x && $x[0]['total'] > 1) ? true : false);
+
+ $tabs = array(
+ array(
+ 'label' => t('Account settings'),
+ 'url' => z_root().'/settings/account',
+ 'selected' => ((argv(1) === 'account') ? 'active' : ''),
+ ),
+
+ array(
+ 'label' => t('Channel settings'),
+ 'url' => z_root().'/settings/channel',
+ 'selected' => ((argv(1) === 'channel') ? 'active' : ''),
+ ),
+
+ );
+
+ if(get_account_techlevel() > 0 && get_features()) {
+ $tabs[] = array(
+ 'label' => t('Additional features'),
+ 'url' => z_root().'/settings/features',
+ 'selected' => ((argv(1) === 'features') ? 'active' : ''),
+ );
+ }
+
+ $tabs[] = array(
+ 'label' => t('Feature/Addon settings'),
+ 'url' => z_root().'/settings/featured',
+ 'selected' => ((argv(1) === 'featured') ? 'active' : ''),
+ );
+
+ $tabs[] = array(
+ 'label' => t('Display settings'),
+ 'url' => z_root().'/settings/display',
+ 'selected' => ((argv(1) === 'display') ? 'active' : ''),
+ );
+
+ if($hublocs) {
+ $tabs[] = array(
+ 'label' => t('Manage locations'),
+ 'url' => z_root() . '/locs',
+ 'selected' => ((argv(1) === 'locs') ? 'active' : ''),
+ );
+ }
+
+ $tabs[] = array(
+ 'label' => t('Export channel'),
+ 'url' => z_root() . '/uexport',
+ 'selected' => ''
+ );
+
+ $tabs[] = array(
+ 'label' => t('Connected apps'),
+ 'url' => z_root() . '/settings/oauth',
+ 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
+ );
+
+ if(get_account_techlevel() > 2) {
+ $tabs[] = array(
+ 'label' => t('Guest Access Tokens'),
+ 'url' => z_root() . '/settings/tokens',
+ 'selected' => ((argv(1) === 'tokens') ? 'active' : ''),
+ );
+ }
+
+ if(feature_enabled(local_channel(),'permcats')) {
+ $tabs[] = array(
+ 'label' => t('Permission Groups'),
+ 'url' => z_root() . '/settings/permcats',
+ 'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
+ );
+ }
+
+
+ if($role === false || $role === 'custom') {
+ $tabs[] = array(
+ 'label' => t('Connection Default Permissions'),
+ 'url' => z_root() . '/connedit/' . $abook_self_id,
+ 'selected' => ''
+ );
+ }
+
+ if(feature_enabled(local_channel(),'premium_channel')) {
+ $tabs[] = array(
+ 'label' => t('Premium Channel Settings'),
+ 'url' => z_root() . '/connect/' . $channel['channel_address'],
+ 'selected' => ''
+ );
+ }
+
+ if(feature_enabled(local_channel(),'channel_sources')) {
+ $tabs[] = array(
+ 'label' => t('Channel Sources'),
+ 'url' => z_root() . '/sources',
+ 'selected' => ''
+ );
+ }
+
+ $tabtpl = get_markup_template("generic_links_widget.tpl");
+ return replace_macros($tabtpl, array(
+ '$title' => t('Settings'),
+ '$class' => 'settings-widget',
+ '$items' => $tabs,
+ ));
+ }
+
+} \ No newline at end of file
diff --git a/Zotlabs/Widget/Tagcloud_wall.php b/Zotlabs/Widget/Tagcloud_wall.php
new file mode 100644
index 000000000..7cff6ce09
--- /dev/null
+++ b/Zotlabs/Widget/Tagcloud_wall.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Tagcloud_wall {
+
+ function widget($arr) {
+
+ if((! \App::$profile['profile_uid']) || (! \App::$profile['channel_hash']))
+ return '';
+ if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_stream'))
+ return '';
+
+ $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50);
+ if(feature_enabled(\App::$profile['profile_uid'], 'tagadelic'))
+ return wtagblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash'], 'wall');
+
+ return '';
+ }
+}