From 1ebaacfd5e7e481cbc025842e78161f79f5d7cce Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 17:50:24 -0700 Subject: menu export --- include/identity.php | 12 +++++++++++- version.inc | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/identity.php b/include/identity.php index 76079e93a..4d2f8b961 100644 --- a/include/identity.php +++ b/include/identity.php @@ -5,7 +5,7 @@ require_once('include/zot.php'); require_once('include/crypto.php'); - +require_once('include/menu.php'); /** * @brief Called when creating a new channel. @@ -601,6 +601,16 @@ function identity_basic_export($channel_id, $items = false) { $ret['event_item'][] = encode_item($rr,true); } + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } + if(! $items) return $ret; diff --git a/version.inc b/version.inc index 89a33f525..5842b45a1 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-09-07.1148 +2015-09-08.1149 -- cgit v1.2.3 From 75d521d42affbafa34e87752deeb1961367de1d5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 17:51:48 -0700 Subject: menu import and sync --- include/Import/import_diaspora.php | 5 +- include/identity.php | 11 ++++ include/import.php | 124 +++++++++++++++++++++++++++++++++++++ include/menu.php | 13 +++- include/zot.php | 3 + mod/import.php | 3 + mod/menu.php | 8 ++- mod/mitem.php | 3 + 8 files changed, 167 insertions(+), 3 deletions(-) diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php index fca9fa4f2..a0f473b50 100644 --- a/include/Import/import_diaspora.php +++ b/include/Import/import_diaspora.php @@ -57,6 +57,10 @@ function import_diaspora($data) { $channel_id = $c['channel']['channel_id']; + // Hubzilla only: Turn on the Diaspora protocol so that follow requests will be sent. + + set_pconfig($channel_id,'system','diaspora_allowed','1'); + // todo - add auto follow settings, (and strip exif in hubzilla) $location = escape_tags($data['user']['profile']['location']); @@ -70,7 +74,6 @@ function import_diaspora($data) { ); if($data['user']['profile']['nsfw']) { - // fixme for hubzilla which doesn't use pageflags any more q("update channel set channel_pageflags = (channel_pageflags | %d) where channel_id = %d", intval(PAGE_ADULT), intval($channel_id) diff --git a/include/identity.php b/include/identity.php index 211832d51..f68b1fe4a 100644 --- a/include/identity.php +++ b/include/identity.php @@ -5,6 +5,7 @@ require_once('include/zot.php'); require_once('include/crypto.php'); +require_once('include/menu.php'); /** @@ -595,6 +596,16 @@ function identity_basic_export($channel_id, $items = false) { foreach($r as $rr) $ret['event_item'][] = encode_item($rr,true); } + + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } if(! $items) diff --git a/include/import.php b/include/import.php index 616ee4987..7b2f574d9 100644 --- a/include/import.php +++ b/include/import.php @@ -1,5 +1,6 @@ = $m['menu_edited']) + continue; + if($menu['menu_deleted']) { + menu_delete_id($r[0]['menu_id'],$channel['channel_id']); + continue; + } + $menu_id = $r[0]['menu_id']; + $x = menu_edit($m); + if(! $x) + continue; + $editing = true; + } + if(! $editing) { + $menu_id = menu_create($m); + } + if($menu_id) { + if($editing) { + // don't try syncing - just delete all the entries and start over + q("delete from menu_item where mitem_menu_id = %d", + intval($menu_id) + ); + } + + if(is_array($menu['items'])) { + foreach($menu['items'] as $it) { + $mitem = array(); + + $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']); + $mitem['mitem_desc'] = escape_tags($it['desc']); + $mitem['mitem_order'] = intval($it['order']); + if(is_array($it['flags'])) { + $mitem['mitem_flags'] = 0; + if(in_array('zid',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_ZID; + if(in_array('new-window',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN; + if(in_array('chatroom',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM; + } + menu_add_item($menu_id,$channel['channel_id'],$mitem); + } + } + } + } + } +} diff --git a/include/menu.php b/include/menu.php index 7ed931a59..32d8630a6 100644 --- a/include/menu.php +++ b/include/menu.php @@ -6,7 +6,7 @@ require_once('include/bbcode.php'); function menu_fetch($name,$uid,$observer_xchan) { - $sql_options = permissions_sql($uid); + $sql_options = permissions_sql($uid,$observer_xchan); $r = q("select * from menu where menu_channel_id = %d and menu_name = '%s' limit 1", intval($uid), @@ -388,3 +388,14 @@ function menu_del_item($menu_id,$uid,$item_id) { return $r; } +function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { + $r = menu_fetch_id($menu_id,$uid); + if($r) { + $m = menu_fetch($r[0]['menu_name'],$uid,$observer_hash); + if($m) { + if($delete) + $m['menu_delete'] = 1; + build_sync_packet($uid,array('menu' => array(menu_element($m)))); + } + } +} diff --git a/include/zot.php b/include/zot.php index 285668209..9fac4d40e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2896,6 +2896,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('item_id',$arr) && $arr['item_id']) sync_items($channel,$arr['item_id']); + if(array_key_exists('menu',$arr) && $arr['menu']) + sync_menus($channel,$arr['menu']); + if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { if(array_key_exists('channel_page_flags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) { $arr['channel']['channel_removed'] = (($arr['channel']['channel_pageflags'] & 0x8000) ? 1 : 0); diff --git a/mod/import.php b/mod/import.php index 27c2094c3..0e43d2444 100644 --- a/mod/import.php +++ b/mod/import.php @@ -443,6 +443,9 @@ function import_post(&$a) { if(is_array($data['event_item'])) import_items($channel,$data['event_item']); + + if(is_array($data['menu'])) + import_menus($channel,$data['menu']); $saved_notification_flags = notifications_off($channel['channel_id']); diff --git a/mod/menu.php b/mod/menu.php index 7763c4ed1..bfc45adef 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -37,6 +37,7 @@ function menu_post(&$a) { $_REQUEST['menu_id'] = intval(argv(1)); $r = menu_edit($_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$menu_id); //info( t('Menu updated.') . EOL); goaway(z_root() . '/mitem/' . $menu_id . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -45,7 +46,9 @@ function menu_post(&$a) { } else { $r = menu_create($_REQUEST); - if($r) { + if($r) { + menu_sync_packet($uid,get_observer_hash(),$r); + //info( t('Menu created.') . EOL); goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -56,6 +59,8 @@ function menu_post(&$a) { } + + function menu_content(&$a) { $uid = local_channel(); @@ -121,6 +126,7 @@ function menu_content(&$a) { if(intval(argv(1))) { if(argc() == 3 && argv(2) == 'drop') { + menu_sync_packet($uid,get_observer_hash(),intval(argv(1)),true); $r = menu_delete_id(intval(argv(1)),$uid); if(!$r) notice( t('Menu could not be deleted.'). EOL); diff --git a/mod/mitem.php b/mod/mitem.php index 0fadd1548..0c3f83bdd 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -64,6 +64,7 @@ function mitem_post(&$a) { $_REQUEST['mitem_id'] = $mitem_id; $r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element updated.') . EOL); goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -74,6 +75,7 @@ function mitem_post(&$a) { else { $r = menu_add_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element added.') . EOL); if($_REQUEST['submit']) { goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : '')); @@ -203,6 +205,7 @@ function mitem_content(&$a) { if(argc() == 4 && argv(3) == 'drop') { $r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2))); + menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); if($r) info( t('Menu item deleted.') . EOL); else -- cgit v1.2.3 From 50d7554ccd36d483a7fc205215e0d980232ce368 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 18:40:19 -0700 Subject: add sync packets for menus --- include/menu.php | 11 +++++++++++ mod/menu.php | 6 +++++- mod/mitem.php | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/menu.php b/include/menu.php index d20df1d6e..fc8aa1386 100644 --- a/include/menu.php +++ b/include/menu.php @@ -388,3 +388,14 @@ function menu_del_item($menu_id,$uid,$item_id) { return $r; } +function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { + $r = menu_fetch_id($menu_id,$uid); + if($r) { + $m = menu_fetch($r['menu_name'],$uid,$observer_hash); + if($m) { + if($delete) + $m['menu_delete'] = 1; + build_sync_packet($uid,array('menu' => array(menu_element($m)))); + } + } +} diff --git a/mod/menu.php b/mod/menu.php index 7763c4ed1..a0a300000 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -37,6 +37,7 @@ function menu_post(&$a) { $_REQUEST['menu_id'] = intval(argv(1)); $r = menu_edit($_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$menu_id); //info( t('Menu updated.') . EOL); goaway(z_root() . '/mitem/' . $menu_id . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -45,7 +46,9 @@ function menu_post(&$a) { } else { $r = menu_create($_REQUEST); - if($r) { + if($r) { + menu_sync_packet($uid,get_observer_hash(),$menu_id); + //info( t('Menu created.') . EOL); goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -121,6 +124,7 @@ function menu_content(&$a) { if(intval(argv(1))) { if(argc() == 3 && argv(2) == 'drop') { + menu_sync_packet($uid,get_observer_hash(),intval(argv(1)),true); $r = menu_delete_id(intval(argv(1)),$uid); if(!$r) notice( t('Menu could not be deleted.'). EOL); diff --git a/mod/mitem.php b/mod/mitem.php index bc93165ac..b62feb97c 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -64,6 +64,7 @@ function mitem_post(&$a) { $_REQUEST['mitem_id'] = $mitem_id; $r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element updated.') . EOL); goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : '')); } @@ -74,6 +75,7 @@ function mitem_post(&$a) { else { $r = menu_add_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { + menu_sync_packet($uid,get_observer_hash(),$menu_id); //info( t('Menu element added.') . EOL); if($_REQUEST['submit']) { goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : '')); @@ -207,6 +209,7 @@ function mitem_content(&$a) { $lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock'); if(argc() == 4 && argv(3) == 'drop') { + menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); $r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2))); if($r) info( t('Menu item deleted.') . EOL); -- cgit v1.2.3 From f0847e6f32ceb5a91109f968225b3492dcfe6c9c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 18:40:56 -0700 Subject: debugging menu sync --- include/import.php | 2 ++ include/menu.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/import.php b/include/import.php index 7b2f574d9..e468889b4 100644 --- a/include/import.php +++ b/include/import.php @@ -690,6 +690,7 @@ function sync_menus($channel,$menus) { } $editing = false; + $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1", dbesc($m['menu_name']), intval($channel['channel_id']) @@ -702,6 +703,7 @@ function sync_menus($channel,$menus) { continue; } $menu_id = $r[0]['menu_id']; + $m['menu_id'] = $r[0]['menu_id']; $x = menu_edit($m); if(! $x) continue; diff --git a/include/menu.php b/include/menu.php index 32d8630a6..075372515 100644 --- a/include/menu.php +++ b/include/menu.php @@ -238,7 +238,6 @@ function menu_edit($arr) { return false; } - $r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1", intval($menu_id), intval($menu_channel_id) @@ -391,7 +390,7 @@ function menu_del_item($menu_id,$uid,$item_id) { function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { $r = menu_fetch_id($menu_id,$uid); if($r) { - $m = menu_fetch($r[0]['menu_name'],$uid,$observer_hash); + $m = menu_fetch($r['menu_name'],$uid,$observer_hash); if($m) { if($delete) $m['menu_delete'] = 1; -- cgit v1.2.3 From d413b6eba800259e0ba843843e7eebb73155cb4e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 18:45:58 -0700 Subject: merge conflicts --- mod/menu.php | 2 +- mod/mitem.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/menu.php b/mod/menu.php index a0a300000..ad47ad1fd 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -47,7 +47,7 @@ function menu_post(&$a) { else { $r = menu_create($_REQUEST); if($r) { - menu_sync_packet($uid,get_observer_hash(),$menu_id); + menu_sync_packet($uid,get_observer_hash(),$r); //info( t('Menu created.') . EOL); goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : '')); diff --git a/mod/mitem.php b/mod/mitem.php index b62feb97c..60d7885dc 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -75,7 +75,7 @@ function mitem_post(&$a) { else { $r = menu_add_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { - menu_sync_packet($uid,get_observer_hash(),$menu_id); + menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element added.') . EOL); if($_REQUEST['submit']) { goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : '')); -- cgit v1.2.3 From e6690c818df5f64f26a92bdbbeb867056bab6a1a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:13:43 -0700 Subject: export TERM_FILE when mirroring --- include/identity.php | 1 + include/items.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/identity.php b/include/identity.php index 4d2f8b961..d84c22693 100644 --- a/include/identity.php +++ b/include/identity.php @@ -666,6 +666,7 @@ function identity_export_year($channel_id,$year,$month = 0) { $target_month = '01'; $ret = array(); + $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00'); if($month && $month < 12) $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00'); diff --git a/include/items.php b/include/items.php index 981f52d7a..3669628b4 100755 --- a/include/items.php +++ b/include/items.php @@ -1260,7 +1260,7 @@ function encode_item($item,$mirror = false) { $x['comment_scope'] = $c_scope; if($item['term']) - $x['tags'] = encode_item_terms($item['term']); + $x['tags'] = encode_item_terms($item['term'],$mirror); if($item['diaspora_meta']) $x['diaspora_signature'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key); @@ -1349,6 +1349,11 @@ function encode_item_terms($terms) { $allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK ); + if($mirror) { + $allowed_export_terms[] = TERM_PCATEGORY; + $allowed_export_terms[] = TERM_FILE; + } + if($terms) { foreach($terms as $term) { if(in_array($term['type'],$allowed_export_terms)) -- cgit v1.2.3 From f13a8f725c393961b4e3cfa79f1eff348f3893f3 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:14:29 -0700 Subject: export TERM_FILE when mirroring --- include/items.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/items.php b/include/items.php index 5d38b0982..4c21d55a1 100755 --- a/include/items.php +++ b/include/items.php @@ -1309,7 +1309,7 @@ function encode_item($item,$mirror = false) { $x['comment_scope'] = $c_scope; if($item['term']) - $x['tags'] = encode_item_terms($item['term']); + $x['tags'] = encode_item_terms($item['term'],$mirror); if($item['diaspora_meta']) { $z = json_decode($item['diaspora_meta'],true); @@ -1401,11 +1401,16 @@ function encode_item_xchan($xchan) { return $ret; } -function encode_item_terms($terms) { +function encode_item_terms($terms,$mirror = false) { $ret = array(); $allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK ); + if($mirror) { + $allowed_export_terms[] = TERM_PCATEGORY; + $allowed_export_terms[] = TERM_FILE; + } + if($terms) { foreach($terms as $term) { if(in_array($term['type'],$allowed_export_terms)) -- cgit v1.2.3 From e8d431c2f641221712cce974eced27d600c168c1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:51:52 -0700 Subject: issues with "use this photo for profile photo" #36 --- mod/profile_photo.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 13923a655..9f57c3b9d 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -130,7 +130,7 @@ function profile_photo_post(&$a) { if($r) { $base_image = $r[0]; - $base_image['data'] = dbunescbin($base_image['data']); + $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data'])); $im = photo_factory($base_image['data'], $base_image['type']); if($im->is_valid()) { @@ -332,7 +332,7 @@ function profile_photo_content(&$a) { goaway($a->get_baseurl() . '/profiles'); } - $r = q("SELECT `data`, `type` FROM photo WHERE id = %d and uid = %d limit 1", + $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()) @@ -342,9 +342,31 @@ function profile_photo_content(&$a) { return; } - $ph = photo_factory(dbunescbin($r[0]['data']), $r[0]['type']); - // go ahead as if we have just uploaded a new photo to crop - profile_photo_crop_ui_head($a, $ph); + if(intval($r[0]['os_storage'])) + $data = @file_get_contents($r[0]['data']); + else + $data = dbunescbin($r[0]['data']); + + $ph = photo_factory($data, $r[0]['type']); + $smallest = 0; + if($ph->is_valid()) { + // go ahead as if we have just uploaded a new photo to crop + $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d order by scale", + dbesc($r[0]['resource_id']), + intval(local_channel()) + ); + + if($i) { + $hash = $i[0]['resource_id']; + foreach($i as $ii) { + if(intval($ii['scale']) < 2) { + $smallest = intval($ii['scale']); + } + } + } + } + + profile_photo_crop_ui_head($a, $ph, $hash, $smallest); } $profiles = q("select id, profile_name as name, is_default from profile where uid = %d", -- cgit v1.2.3 From 2aaee311f30913d0add3f9200af4f54520defc51 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:57:07 -0700 Subject: differentiate Community Server from Enterprise Server --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44357eb3c..9de6393b1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Hubzilla -======== +Hubzilla - Community Server +=========================== Websites. Redefined. -------------------- -- cgit v1.2.3 From d702133ded36f23a79f7aed22c7d20ad263cff7b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 20:48:35 -0700 Subject: move mod_admin to Comanche finally --- doc/to_do_code.bb | 2 +- include/widgets.php | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ mod/admin.php | 42 ----------------------------------- view/pdl/mod_admin.pdl | 3 +++ 4 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 view/pdl/mod_admin.pdl diff --git a/doc/to_do_code.bb b/doc/to_do_code.bb index 94421bab0..90c5f78e5 100644 --- a/doc/to_do_code.bb +++ b/doc/to_do_code.bb @@ -45,7 +45,7 @@ We need much more than this, but here are areas where developers can help. Pleas [li]Create mobile clients for the top platforms - which involves extending the API so that we can do stuff far beyond the current crop of Twitter/Statusnet clients. Ditto for mobile themes. We can probably use something like the Friendica Android app as a base to start from.[/li] [li](in progress Habeas Codice) Implement owned and exchangeable "things".[/li] [li]Family Account creation - using service classes (an account holder can create a certain number of sub-accounts which are all tied to their subscription - if the subscription lapses they all go away).[/li] -[li]Put mod_admin under Comanche[/li] + In many cases some of the work has already been started and code exists so that you needn't start from scratch. Please contact one of the developer channels like Channel One (one@zothub.com) before embarking and we can tell you what we already have and provide some insights on how we envision these features fitting together. diff --git a/include/widgets.php b/include/widgets.php index 42d9db19a..8c5e92140 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1074,4 +1074,63 @@ function widget_helpindex($arr) { $o .= ''; return $o; +} + + + +function widget_admin($arr) { + + /* + * Side bar links + */ + + if(! is_site_admin()) { + return login(false); + } + + + $a = get_app(); + $o = ''; + + // array( url, name, extra css classes ) + + $aside = array( + 'site' => array(z_root() . '/admin/site/', t('Site'), 'site'), + 'users' => array(z_root() . '/admin/users/', t('Accounts'), 'users'), + 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), + 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), + 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), + 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), + 'dbsync' => array(z_root() . '/admin/dbsync/', t('DB updates'), 'dbsync') + + ); + + /* get plugins admin page */ + + $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); + + $aside['plugins_admin'] = array(); + if($r) { + foreach ($r as $h){ + $plugin = $h['name']; + $aside['plugins_admin'][] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); + // temp plugins with admin + $a->plugins_admin[] = $plugin; + } + } + + $aside['logs'] = array(z_root() . '/admin/logs/', t('Logs'), 'logs'); + + $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( + '$admin' => $aside, + '$admtxt' => t('Admin'), + '$plugadmtxt' => t('Plugin Features'), + '$logtxt' => t('Logs'), + '$h_pending' => t('User registrations waiting for confirmation'), + '$admurl'=> z_root() . '/admin/' + )); + + return $o; + } \ No newline at end of file diff --git a/mod/admin.php b/mod/admin.php index 89207e4fa..2b7bb007d 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -84,48 +84,6 @@ function admin_content(&$a) { return login(false); } - /* - * Side bar links - */ - - // array( url, name, extra css classes ) - - $aside = array( - 'site' => array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"), - 'users' => array($a->get_baseurl(true)."/admin/users/", t("Accounts") , "users"), - 'channels' => array($a->get_baseurl(true)."/admin/channels/", t("Channels") , "channels"), - 'plugins' => array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), - 'themes' => array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), - 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), -// 'hubloc' => array($a->get_baseurl(true)."/admin/hubloc/", t("Server") , "server"), - 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), - 'dbsync' => array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync") - - ); - - /* get plugins admin page */ - - $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); - $aside['plugins_admin'] = array(); - foreach ($r as $h){ - $plugin = $h['name']; - $aside['plugins_admin'][] = array($a->get_baseurl(true) . '/admin/plugins/' . $plugin, $plugin, 'plugin'); - // temp plugins with admin - $a->plugins_admin[] = $plugin; - } - - $aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs"); - - $t = get_markup_template("admin_aside.tpl"); - $a->page['aside'] .= replace_macros( $t, array( - '$admin' => $aside, - '$admtxt' => t('Admin'), - '$plugadmtxt' => t('Plugin Features'), - '$logtxt' => t('Logs'), - '$h_pending' => t('User registrations waiting for confirmation'), - '$admurl'=> $a->get_baseurl(true)."/admin/" - )); - /* * Page content diff --git a/view/pdl/mod_admin.pdl b/view/pdl/mod_admin.pdl new file mode 100644 index 000000000..5bd47ea37 --- /dev/null +++ b/view/pdl/mod_admin.pdl @@ -0,0 +1,3 @@ +[region=aside] +[widget=admin][/widget] +[/region] \ No newline at end of file -- cgit v1.2.3 From 0a051ff2cd13eb33ecffc3c4e34a1a56a3fcf29a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 22:46:34 -0700 Subject: preserve code blocks on item import if channel has code rights. When importing the channel itself, turn code access off unless this is the admin. --- include/api.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ include/import.php | 18 +++++++++++++++++- include/items.php | 17 +++++++++++++++-- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/include/api.php b/include/api.php index 6d71cfc33..a77bf15f7 100644 --- a/include/api.php +++ b/include/api.php @@ -896,6 +896,55 @@ require_once('include/items.php'); api_register_func('api/red/item/new','red_item_new', true); + function red_item(&$a, $type) { + + if (api_user() === false) { + logger('api_red_item_new: no user'); + return false; + } + + if($_REQUEST['mid']) { + $arr = array('mid' => $_REQUEST['mid']); + } + elseif($_REQUEST['item_id']) { + $arr = array('item_id' => $_REQUEST['item_id']); + } + else + json_return_and_die(array()); + + $arr['start'] = 0; + $arr['records'] = 999999; + $arr['item_type'] = '*'; + + $i = items_fetch($arr,$a->get_channel(),get_observer_hash()); + + if(! $i) + json_return_and_die(array()); + + $ret = array(); + $tmp = array(); + $str = ''; + foreach($i as $ii) { + $tmp[] = encode_item($ii,true); + if($str) + $str .= ','; + $str .= $ii['id']; + } + $ret['item'] = $tmp; + if($str) { + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item.id in ( $str ) "); + + if($r) + $ret['item_id'] = $r; + } + + json_return_and_die($ret); + } + + api_register_func('api/red/item/full','red_item', true); + + + function api_get_status($xchan_hash) { require_once('include/security.php'); diff --git a/include/import.php b/include/import.php index e468889b4..168446be9 100644 --- a/include/import.php +++ b/include/import.php @@ -50,6 +50,11 @@ function import_channel($channel) { unset($channel['channel_id']); $channel['channel_account_id'] = get_account_id(); $channel['channel_primary'] = (($seize) ? 1 : 0); + + if($channel['channel_pageflags'] & PAGE_ALLOWCODE) { + if(! is_site_admin()) + $channel['channel_pageflags'] = $channel['channel_pageflags'] ^ PAGE_ALLOWCODE; + } dbesc_array($channel); @@ -480,8 +485,19 @@ function sync_chatrooms($channel,$chatrooms) { function import_items($channel,$items) { if($channel && $items) { + $allow_code = false; + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id + where channel_id = %d limit 1", + intval($channel['channel_id']) + ); + if($r) { + if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { + $allow_code = true; + } + } + foreach($items as $i) { - $item = get_item_elements($i); + $item = get_item_elements($i,$allow_code); if(! $item) continue; diff --git a/include/items.php b/include/items.php index 4c21d55a1..28fd8502b 100755 --- a/include/items.php +++ b/include/items.php @@ -833,10 +833,13 @@ function title_is_body($title, $body) { } -function get_item_elements($x) { +function get_item_elements($x,$allow_code = false) { $arr = array(); - $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); + if($allow_code) + $arr['body'] = $x['body']; + else + $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); $key = get_config('system','pubkey'); @@ -4731,6 +4734,12 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C if($arr['wall']) $sql_options .= " and item_wall = 1 "; + + if($arr['item_id']) + $sql_options .= " and parent = " . intval($arr['item_id']) . " "; + + if($arr['mid']) + $sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' "; $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) "; @@ -4857,11 +4866,15 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash); + if($arr['pages']) $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " "; else $item_restrict = " AND item_type = 0 "; + if($arr['item_type'] === '*') + $item_restrict = ''; + if ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD) && $channel) { // "New Item View" - show all items unthreaded in reverse created date order -- cgit v1.2.3