From 9f37dbc6dc1798b9b56a683ed1975adc318ff931 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 22 Aug 2017 18:29:51 -0700 Subject: util/dcp - support recursion and folders full of photos by importing files singly in separate processes - not yet tested --- include/attach.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') 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']); -- cgit v1.2.3 From e084b776eee9f1fc66e3f4a37b92ec70ccc49286 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 00:01:02 -0700 Subject: cards feature --- include/contact_widgets.php | 43 +++++++++++++++++++++++++ include/conversation.php | 16 ++++++++-- include/features.php | 9 ++++++ include/nav.php | 12 +++++++ include/taxonomy.php | 76 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 2 deletions(-) (limited to 'include') 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..c9142ac30 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1835,7 +1835,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 +1847,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 +1868,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 @@ -117,6 +117,15 @@ function get_features($filtered = true) { feature_level('private_notes',1), ], + [ + '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'), 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 = '

' . t('Categories') . '

'; + foreach($r as $rr) { + $o .= ''.$rr[0].' ' . "\r\n"; + } + $o .= '
'; + } + + return $o; +} + function dir_tagblock($link,$r) { $o = ''; -- cgit v1.2.3 From 3b68df1be6173cbcc50386efc0161ece2015112d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 17:46:20 -0700 Subject: several card enhancements --- include/conversation.php | 7 ++++++- include/items.php | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c9142ac30..e0de6fdce 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1305,6 +1305,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 +1354,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'), 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 -- cgit v1.2.3 From 64cf36a2b5dc314728fbb262471f1dd7b0ad2d96 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 19:25:42 -0700 Subject: lognoise: don't log sync packet contents if there are no clones to receive them --- include/zot.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') 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 -- cgit v1.2.3 From f2e802229acb871e0b50afb729445cdef8586951 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 20:02:28 -0700 Subject: add new conv_sort option --- include/conversation.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index e0de6fdce..2448775af 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1461,6 +1461,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'); @@ -1502,6 +1504,10 @@ function sort_thr_commented($a,$b) { return strcmp($b['commented'],$a['commented']); } +function sort_thr_updated($a,$b) { + return strcmp($b['updated'],$a['updated']); +} + function find_thread_parent_index($arr,$x) { foreach($arr as $k => $v) if($v['id'] == $x['parent']) -- cgit v1.2.3 From e7788156052bcb3676fe761f89769c2d72dc4bca Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 20:12:40 -0700 Subject: use two keys for the updated sort --- include/conversation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 2448775af..7e0394058 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1505,7 +1505,9 @@ function sort_thr_commented($a,$b) { } function sort_thr_updated($a,$b) { - return strcmp($b['updated'],$a['updated']); + $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) { -- cgit v1.2.3 From 4450170790de3999dc9c6f8876074e76edee8241 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 21:26:09 -0700 Subject: partial support (unfinished) for ajax loading cards with liveupdate; page still functions even though this isn't finished --- include/conversation.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 7e0394058..0d2dd2224 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -517,6 +517,15 @@ 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 = '
' . "\r\n" + . "\r\n"; + } + + elseif ($mode === 'display') { $profile_owner = local_channel(); $page_writeable = false; -- cgit v1.2.3 From e157e3bec8722c04ed8dc2d215cd2efd0ce3ce79 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 22:06:42 -0700 Subject: cards: make page load after comment post --- include/conversation.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 0d2dd2224..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 ' : ''); @@ -523,6 +524,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $live_update_div = '
' . "\r\n" . "\r\n"; + $jsreload = $_SESSION['return_url']; } @@ -817,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); + } + } } -- cgit v1.2.3