aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Manning <andrewmanning@grid.reticu.li>2017-08-24 18:57:52 +0000
committerAndrew Manning <andrewmanning@grid.reticu.li>2017-08-24 18:57:52 +0000
commit90ec3340e44a3d3c69779f0db33ee49e864f326d (patch)
tree2b0bc859c3a7d31adcd1c9777d9868b9dbecdeda /include
parentcf2609530fcffdc7f5477336232b7cfde8b6403f (diff)
parentcdccf601320ec7e59f5d96438edac34d5ea30085 (diff)
downloadvolse-hubzilla-90ec3340e44a3d3c69779f0db33ee49e864f326d.tar.gz
volse-hubzilla-90ec3340e44a3d3c69779f0db33ee49e864f326d.tar.bz2
volse-hubzilla-90ec3340e44a3d3c69779f0db33ee49e864f326d.zip
Merge remote-tracking branch 'upstream/dev' into doco
Diffstat (limited to 'include')
-rw-r--r--include/attach.php8
-rw-r--r--include/contact_widgets.php43
-rw-r--r--include/conversation.php46
-rw-r--r--include/features.php9
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/nav.php12
-rw-r--r--include/taxonomy.php76
-rw-r--r--include/zot.php5
8 files changed, 195 insertions, 6 deletions
diff --git a/include/attach.php b/include/attach.php
index 79a38590b..78e133b03 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -460,6 +460,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
// By default remove $src when finished
$remove_when_processed = true;
+ $import_replace = false;
if($options === 'import') {
$src = $arr['src'];
@@ -476,6 +477,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($arr['preserve_original'])
$remove_when_processed = false;
+ if($arr['replace'])
+ $import_replace = true;
+
// if importing a directory, just do it now and go home - we're done.
if(array_key_exists('is_dir',$arr) && intval($arr['is_dir'])) {
@@ -617,8 +621,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($folder_hash)
);
if($r) {
- $overwrite = get_pconfig($channel_id,'system','overwrite_dup_files');
+ $overwrite = (($import_replace || get_pconfig($channel_id,'system','overwrite_dup_files')) ? true : false);
if(($overwrite) || ($options === 'import')) {
+ if(! array_key_exists('edited',$arr))
+ $arr['edited'] = datetime_convert();
$options = 'replace';
$existing_id = $x[0]['id'];
$existing_size = intval($x[0]['filesize']);
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index 8f76bb4bc..aac756a46 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -100,6 +100,49 @@ function categories_widget($baseurl,$selected = '') {
return '';
}
+function cardcategories_widget($baseurl,$selected = '') {
+
+ if(! feature_enabled(App::$profile['profile_uid'],'categories'))
+ return '';
+
+ $item_normal = "and item.item_hidden = 0 and item.item_type = 6 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ and item.item_blocked = 0 ";
+
+ $terms = array();
+ $r = q("select distinct(term.term)
+ from term join item on term.oid = item.id
+ where item.uid = %d
+ and term.uid = item.uid
+ and term.ttype = %d
+ and term.otype = %d
+ and item.owner_xchan = '%s'
+ $item_normal
+ order by term.term asc",
+ intval(App::$profile['profile_uid']),
+ intval(TERM_CATEGORY),
+ intval(TERM_OBJ_POST),
+ dbesc(App::$profile['channel_hash'])
+ );
+ if($r && count($r)) {
+ foreach($r as $rr)
+ $terms[] = array('name' => $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : ''));
+
+ return replace_macros(get_markup_template('categories_widget.tpl'),array(
+ '$title' => t('Categories'),
+ '$desc' => '',
+ '$sel_all' => (($selected == '') ? 'selected' : ''),
+ '$all' => t('Everything'),
+ '$terms' => $terms,
+ '$base' => $baseurl,
+
+ ));
+ }
+ return '';
+}
+
+
+
function common_friends_visitor_widget($profile_uid) {
if(local_channel() == $profile_uid)
diff --git a/include/conversation.php b/include/conversation.php
index 3b8ec19d3..2d5ccb5b1 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -464,6 +464,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$profile_owner = 0;
$page_writeable = false;
$live_update_div = '';
+ $jsreload = '';
$preview = (($page_mode === 'preview') ? true : false);
$previewing = (($preview) ? ' preview ' : '');
@@ -517,6 +518,16 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
}
}
+ elseif ($mode === 'cards') {
+ $profile_owner = App::$profile['profile_uid'];
+ $page_writeable = ($profile_owner == local_channel());
+ $live_update_div = '<div id="live-cards"></div>' . "\r\n"
+ . "<script> var profile_uid = " . App::$profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n";
+ $jsreload = $_SESSION['return_url'];
+ }
+
+
elseif ($mode === 'display') {
$profile_owner = local_channel();
$page_writeable = false;
@@ -808,6 +819,10 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$item_object->set_template('conv_list.tpl');
$item_object->set_display_mode('list');
}
+ if($page_mode === 'cards') {
+ $item_object->set_reload($jsreload);
+ }
+
}
}
@@ -1305,6 +1320,11 @@ function status_editor($a, $x, $popup = false) {
if(! $cipher)
$cipher = 'aes256';
+ if(array_key_exists('catsenabled',$x))
+ $catsenabled = $x['catsenabled'];
+ else
+ $catsenabled = ((feature_enabled($x['profile_uid'], 'categories') && (! $webpage)) ? 'categories' : '');
+
// avoid illegal offset errors
if(! array_key_exists('permissions',$x))
$x['permissions'] = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ];
@@ -1349,7 +1369,7 @@ function status_editor($a, $x, $popup = false) {
'$clearloc' => $clearloc,
'$title' => ((x($x, 'title')) ? htmlspecialchars($x['title'], ENT_COMPAT,'UTF-8') : ''),
'$placeholdertitle' => ((x($x, 'placeholdertitle')) ? $x['placeholdertitle'] : t('Title (optional)')),
- '$catsenabled' => ((feature_enabled($x['profile_uid'], 'categories') && (! $webpage)) ? 'categories' : ''),
+ '$catsenabled' => $catsenabled,
'$category' => ((x($x, 'category')) ? $x['category'] : ''),
'$placeholdercategory' => t('Categories (optional, comma-separated list)'),
'$permset' => t('Permission settings'),
@@ -1456,6 +1476,8 @@ function conv_sort($arr, $order) {
usort($parents,'sort_thr_created');
elseif(stristr($order,'commented'))
usort($parents,'sort_thr_commented');
+ elseif(stristr($order,'updated'))
+ usort($parents,'sort_thr_updated');
elseif(stristr($order,'ascending'))
usort($parents,'sort_thr_created_rev');
@@ -1497,6 +1519,12 @@ function sort_thr_commented($a,$b) {
return strcmp($b['commented'],$a['commented']);
}
+function sort_thr_updated($a,$b) {
+ $indexa = (($a['changed'] > $a['edited']) ? $a['changed'] : $a['edited']);
+ $indexb = (($b['changed'] > $b['edited']) ? $b['changed'] : $b['edited']);
+ return strcmp($indexb,$indexa);
+}
+
function find_thread_parent_index($arr,$x) {
foreach($arr as $k => $v)
if($v['id'] == $x['parent'])
@@ -1835,7 +1863,8 @@ function profile_tabs($a, $is_owner = false, $nickname = null){
require_once('include/menu.php');
$has_bookmarks = menu_list_count(local_channel(),'',MENU_BOOKMARK) + menu_list_count(local_channel(),'',MENU_SYSTEM|MENU_BOOKMARK);
- if ($is_owner && $has_bookmarks) {
+
+ if($is_owner && $has_bookmarks) {
$tabs[] = array(
'label' => t('Bookmarks'),
'url' => z_root() . '/bookmarks',
@@ -1846,6 +1875,17 @@ function profile_tabs($a, $is_owner = false, $nickname = null){
);
}
+ if(feature_enabled($uid,'cards')) {
+ $tabs[] = array(
+ 'label' => t('Cards'),
+ 'url' => z_root() . '/cards/' . $nickname,
+ 'sel' => ((argv(0) == 'cards') ? 'active' : ''),
+ 'title' => t('View Cards'),
+ 'id' => 'cards-tab',
+ 'icon' => 'list'
+ );
+ }
+
if($has_webpages && feature_enabled($uid,'webpages')) {
$tabs[] = array(
'label' => t('Webpages'),
@@ -1856,7 +1896,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){
'icon' => 'newspaper-o'
);
}
-
+
if ($p['view_wiki']) {
if(feature_enabled($uid,'wiki') && (get_account_techlevel($account_id) > 3)) {
diff --git a/include/features.php b/include/features.php
index f32dbe82e..f84c9cb05 100644
--- a/include/features.php
+++ b/include/features.php
@@ -118,6 +118,15 @@ function get_features($filtered = true) {
],
[
+ 'cards',
+ t('Cards'),
+ t('Create personal planning cards'),
+ false,
+ get_config('feature_lock','cards'),
+ feature_level('cards',1),
+ ],
+
+ [
'nav_channel_select',
t('Navigation Channel Select'),
t('Change channels directly from within the navigation dropdown menu'),
diff --git a/include/items.php b/include/items.php
index e7bec7f20..070c4571a 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4111,6 +4111,8 @@ function webpage_to_namespace($webpage) {
$page_type = 'BUILDBLOCK';
elseif($webpage == ITEM_TYPE_PDL)
$page_type = 'PDL';
+ elseif($webpage == ITEM_TYPE_CARD)
+ $page_type = 'CARD';
elseif($webpage == ITEM_TYPE_DOC)
$page_type = 'docfile';
else
diff --git a/include/nav.php b/include/nav.php
index 76a8f8fb9..f5a1236a8 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -434,6 +434,18 @@ function channel_apps($is_owner = false, $nickname = null) {
];
}
+ if($p['view_pages'] && feature_enabled($uid,'cards')) {
+ $tabs[] = [
+ 'label' => t('Cards'),
+ 'url' => z_root() . '/cards/' . $nickname ,
+ 'sel' => ((argv(0) == 'cards') ? 'active' : ''),
+ 'title' => t('View Cards'),
+ 'id' => 'cards-tab',
+ 'icon' => 'list'
+ ];
+ }
+
+
if($has_webpages && feature_enabled($uid,'webpages')) {
$tabs[] = [
'label' => t('Webpages'),
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 46d661581..36e05b008 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -199,6 +199,62 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
}
+
+
+function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $restrict = 0, $type = TERM_CATEGORY) {
+
+ require_once('include/security.php');
+
+ if(! perm_is_allowed($uid,get_observer_hash(),'view_pages'))
+ return array();
+
+
+ $item_normal = item_normal();
+ $sql_options = item_permissions_sql($uid);
+ $count = intval($count);
+
+ if($flags) {
+ if($flags === 'wall')
+ $sql_options .= " and item_wall = 1 ";
+ }
+
+ if($authors) {
+ if(! is_array($authors))
+ $authors = array($authors);
+
+ stringify_array_elms($authors,true);
+ $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
+ }
+
+ if($owner) {
+ $sql_options .= " and owner_xchan = '" . dbesc($owner) . "' ";
+ }
+
+
+ // Fetch tags
+ $r = q("select term, count(term) as total from term left join item on term.oid = item.id
+ where term.uid = %d and term.ttype = %d
+ and otype = %d and item_type = %d and item_private = 0
+ $sql_options $item_normal
+ group by term order by total desc %s",
+ intval($uid),
+ intval($type),
+ intval(TERM_OBJ_POST),
+ intval($restrict),
+ ((intval($count)) ? "limit $count" : '')
+ );
+
+ if(! $r)
+ return array();
+
+ return Zotlabs\Text\Tagadelic::calc($r);
+
+}
+
+
+
+
+
function dir_tagadelic($count = 0) {
$count = intval($count);
@@ -316,6 +372,26 @@ function catblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0,$restric
return $o;
}
+function card_catblock($uid,$count = 0,$authors = '',$owner = '', $flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
+ $o = '';
+
+ $r = card_tagadelic($uid,$count,$authors,$owner,$flags,$restrict,$type);
+
+ if($r) {
+ $c = q("select channel_address from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<a href="cards/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
+ }
+
+ return $o;
+}
+
function dir_tagblock($link,$r) {
$o = '';
diff --git a/include/zot.php b/include/zot.php
index 3e2a66734..343bc8ad8 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2965,8 +2965,6 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
logger('build_sync_packet');
- if($packet)
- logger('packet: ' . print_r($packet, true),LOGGER_DATA, LOG_DEBUG);
$keychange = (($packet && array_key_exists('keychange',$packet)) ? true : false);
if($keychange) {
@@ -3033,6 +3031,9 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$env_recips = array();
$env_recips[] = array('guid' => $r[0]['xchan_guid'],'guid_sig' => $r[0]['xchan_guid_sig']);
+ if($packet)
+ logger('packet: ' . print_r($packet, true),LOGGER_DATA, LOG_DEBUG);
+
$info = (($packet) ? $packet : array());
$info['type'] = 'channel_sync';
$info['encoding'] = 'red'; // note: not zot, this packet is very platform specific