diff options
-rw-r--r-- | Zotlabs/Module/Photos.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Profile.php | 13 | ||||
-rw-r--r-- | Zotlabs/Module/Profiles.php | 34 | ||||
-rw-r--r-- | include/attach.php | 35 | ||||
-rw-r--r-- | include/channel.php | 4 | ||||
-rw-r--r-- | include/connections.php | 7 | ||||
-rw-r--r-- | include/nav.php | 1 | ||||
-rw-r--r-- | include/text.php | 4 | ||||
-rwxr-xr-x | view/tpl/nav.tpl | 4 | ||||
-rwxr-xr-x | view/tpl/profile_advanced.tpl | 5 |
10 files changed, 89 insertions, 21 deletions
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index ef1eee399..582174d0e 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -188,13 +188,12 @@ class Photos extends \Zotlabs\Web\Controller { } if((argc() > 2) && (x($_REQUEST,'delete')) && ($_REQUEST['delete'] === t('Delete Photo'))) { - // same as above but remove single photo $ob_hash = get_observer_hash(); if(! $ob_hash) goaway(z_root() . '/' . $_SESSION['photo_return']); - + $r = q("SELECT id, resource_id FROM photo WHERE ( xchan = '%s' or uid = %d ) AND resource_id = '%s' LIMIT 1", dbesc($ob_hash), intval(local_channel()), diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php index 9e868db92..0bc23952b 100644 --- a/Zotlabs/Module/Profile.php +++ b/Zotlabs/Module/Profile.php @@ -60,7 +60,9 @@ class Profile extends \Zotlabs\Web\Controller { } $groups = array(); - + + + $tab = 'profile'; $o = ''; @@ -69,6 +71,15 @@ class Profile extends \Zotlabs\Web\Controller { return; } + + + if(argc() > 2 && argv(2) === 'vcard') { + header('Content-type: text/vcard'); + header('content-disposition: attachment; filename="' . t('vcard') . '-' . $profile['channel_address'] . '.vcf"' ); + echo \App::$profile['profile_vcard']; + killme(); + } + $is_owner = ((local_channel()) && (local_channel() == \App::$profile['profile_uid']) ? true : false); diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 72a056963..e166c3c19 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -319,10 +319,38 @@ class Profiles extends \Zotlabs\Web\Controller { $orig_vcard = (($orig[0]['profile_vcard']) ? \Sabre\VObject\Reader::read($orig[0]['profile_vcard']) : null); - $_REQUEST['fn'] = $name; - $_REQUEST['title'] = $pdesc; + $channel = \App::get_channel(); + + $default_vcard_cat = ((defined('DEFAULT_VCARD_CAT')) ? DEFAULT_VCARD_CAT : 'HOME'); + + $defcard = [ + 'fn' => $name, + 'title' => $pdesc, + 'photo' => $channel['xchan_photo_l'], + 'adr' => [], + 'adr_type' => [ $default_vcard_cat ], + 'tel' => [], + 'tel_type' => [ $default_vcard_cat ], + 'email' => [], + 'email_type' => [ $default_vcard_cat ], + 'impp' => [], + 'impp_type' => [ $default_vcard_cat ], + 'url' => [], + 'url_type' => [ $default_vcard_cat ] + ]; + + $defcard['adr'][] = [ + 0 => '', + 1 => '', + 2 => $address, + 3 => $locality, + 4 => $region, + 5 => $postal_code, + 6 => $country_name + ]; + - $profile_vcard = update_vcard($_REQUEST,$orig_vcard); + $profile_vcard = update_vcard($defcard,$orig_vcard); require_once('include/text.php'); diff --git a/include/attach.php b/include/attach.php index ba2f60a90..dc5bfd308 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1279,8 +1279,10 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { intval($channel_id) ); - if(! $r) + if(! $r) { + attach_drop_photo($channel_id,$resource); return; + } $cloudpath = get_parent_cloudpath($channel_id, $channel_address, $resource); $object = get_file_activity_object($channel_id, $resource, $cloudpath); @@ -1326,19 +1328,10 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { ); if($r[0]['is_photo']) { - $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", - dbesc($resource), - intval($channel_id) - ); - if($x) { - drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); - } - q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'", - intval($channel_id), - dbesc($resource) - ); + attach_drop_photo($channel_id,$resource); } + // update the parent folder's lastmodified timestamp $e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc(datetime_convert()), @@ -1351,6 +1344,24 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { return; } + +function attach_drop_photo($channel_id,$resource) { + + $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", + dbesc($resource), + intval($channel_id) + ); + if($x) { + drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); + } + q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'", + intval($channel_id), + dbesc($resource) + ); + +} + + /** * @brief Returns path to file in cloud/. * diff --git a/include/channel.php b/include/channel.php index 5d92b4769..83f48f361 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1278,10 +1278,14 @@ function advanced_profile(&$a) { // logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA); + $exportlink = ((App::$profile['profile_vcard']) ? zid(z_root() . '/profile/' . App::$profile['channel_address'] . '/vcard') : ''); + return replace_macros($tpl, array( '$title' => t('Profile'), '$canlike' => (($profile['canlike'])? true : false), '$likethis' => t('Like this thing'), + '$export' => t('Export'), + '$exportlink' => $exportlink, '$profile' => $profile, '$fields' => $clean_fields, '$editmenu' => profile_edit_menu(App::$profile['profile_uid']), diff --git a/include/connections.php b/include/connections.php index 31e941e95..def80441a 100644 --- a/include/connections.php +++ b/include/connections.php @@ -632,6 +632,9 @@ function random_profile() { function update_vcard($arr,$vcard = null) { + + // logger('update_vcard: ' . print_r($arr,true)); + $fn = $arr['fn']; @@ -816,8 +819,10 @@ function get_vcard_array($vc,$id) { $type = (($adr['TYPE']) ? vcard_translate_type((string)$adr['TYPE']) : ''); $adrs[] = [ 'type' => $type, - 'address' => escape_tags($adr->getParts()) + 'address' => $adr->getParts() ]; + $last_entry = end($adrs); + array_walk($adrs[$last_entry]['address'],'array_escape_tags'); } } diff --git a/include/nav.php b/include/nav.php index 2762e2a14..e389308ff 100644 --- a/include/nav.php +++ b/include/nav.php @@ -244,6 +244,7 @@ $powered_by = ''; App::$page['nav'] .= replace_macros($tpl, array( '$baseurl' => z_root(), + '$fulldocs' => t('Documentation'), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], '$banner' => $banner, diff --git a/include/text.php b/include/text.php index bc1eff7db..f5b1803c2 100644 --- a/include/text.php +++ b/include/text.php @@ -3128,4 +3128,8 @@ function cleanup_bbcode($body) { function array_trim(&$v,$k) { $v = trim($v); +} + +function array_escape_tags(&$v,$k) { + $v = escape_tags($v); }
\ No newline at end of file diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index bc1e64416..c56bade94 100755 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -213,8 +213,8 @@ <div id="contextual-help-content" class="contextual-help-content"> {{$nav.help.5}} <div class="pull-right"> - <a class="contextual-help-tool" target="hubzilla-help" href="{{$nav.help.0}}" title="{{$nav.help.3}}"><i class="fa fa-question"></i></a> - <a class="contextual-help-tool" href="#" onclick="contextualHelp(); return false;"><i class="fa fa-times"></i></a> + <a class="contextual-help-tool btn btn-primary btn-xs" target="hubzilla-help" href="{{$nav.help.0}}" title="{{$nav.help.3}}"><i class="fa fa-question"></i> {{$fulldocs}}</a> + <a class="contextual-help-tool btn btn-default btn-xs" href="#" onclick="contextualHelp(); return false;"><i class="fa fa-times"></i></a> </div> </div> {{/if}} diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl index 59490ccc1..4000f39d6 100755 --- a/view/tpl/profile_advanced.tpl +++ b/view/tpl/profile_advanced.tpl @@ -34,6 +34,11 @@ <a class="btn btn-primary btn-xs" href="{{$editmenu.edit.0}}" ><i class="fa fa-pencil"></i> {{$editmenu.edit.3}}</a> </div> {{/if}} + {{if $exportlink}} + <div class="btn-group"> + <a class="btn btn-default btn-xs" href="{{$exportlink}}" ><i class="fa fa-vcard"></i> {{$export}}</a> + </div> + {{/if}} </div> <h2>{{$title}}</h2> <div class="clear"></div> |