]> git.mxchange.org Git - friendica.git/commitdiff
use browser geolocation when desired
authorMike Macgirvin <mike@macgirvin.com>
Wed, 20 Oct 2010 03:52:05 +0000 (20:52 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Wed, 20 Oct 2010 03:52:05 +0000 (20:52 -0700)
14 files changed:
boot.php
include/items.php
include/notifier.php
mod/display.php
mod/item.php
mod/network.php
mod/profile.php
mod/settings.php
view/atom_feed.tpl
view/atom_item.tpl
view/jot-header.tpl
view/jot.tpl
view/settings.tpl
view/theme/default/style.css

index 5070f7bac6be23d35649ee7196ae5ed7319d04ce..8fec10afaa9a0040b60868e83b0e1fbf6060c7b7 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -55,6 +55,7 @@ define ( 'NAMESPACE_ACTIVITY',        'http://activitystrea.ms/spec/1.0/' );
 define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
 define ( 'NAMESPACE_SALMON_ME',       'http://salmon-protocol.org/ns/magic-env');
 define ( 'NAMESPACE_OSTATUSSUB',      'http://ostatus.org/schema/1.0/subscribe');
+define ( 'NAMESPACE_GEORSS',          'http://www.georss.org/georss');
 
 // activity stream defines
 
index 87e5b46eff0493c653d8b4f6aaa7580a9ff7238e..f04bf0bd87b71288056690813aaa117efacc0421 100644 (file)
@@ -199,8 +199,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
                                        '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
                                        '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited']  . '+00:00' , ATOM_TIME)),
                                        '$location'           => xmlify($item['location']),
+                                       '$coord'              => xmlify($item['coord']),
                                        '$type'               => $type,
-                                       '$alt'           => xmlify($a->get_baseurl() . '/display/' . $owner_nick . '/' . $item['id']),
+                                       '$alt'                => xmlify($a->get_baseurl() . '/display/' . $owner_nick . '/' . $item['id']),
                                        '$content'            => xmlify($item['body']),
                                        '$verb'               => xmlify($verb),
                                        '$actobj'             => $actobj,  // do not xmlify
@@ -355,6 +356,10 @@ function get_atom_elements($item) {
        elseif($rawowner[0]['child'][NAMESPACE_DFRN]['avatar'][0]['data'])
                $res['owner-avatar'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']);
 
+       $rawgeo = $item->get_item_tags(NAMESPACE_GEORSS,'point');
+       if($rawgeo)
+               $res['coord'] = unxmlify($rawgeo[0]['data']);
+
        $rawverb = $item->get_item_tags(NAMESPACE_ACTIVITY, 'verb');
        // select between supported verbs
        if($rawverb)
@@ -429,6 +434,7 @@ function item_store($arr) {
        $arr['changed'] = datetime_convert();
        $arr['title'] = notags(trim($arr['title']));
        $arr['location'] = notags(trim($arr['location']));
+       $arr['coord'] = notags(trim($arr['coord']));
        $arr['body'] = escape_tags(trim($arr['body']));
        $arr['last-child'] = intval($arr['last-child']);
        $arr['visible'] = ((x($arr,'visible') !== false) ? intval($arr['visible']) : 1);
index db95c3aae49a8c30f224dc656d0fdec38b8cac48..99b3859960da5dbd4bc0797800550410e27cb9e7 100644 (file)
                                                '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
                                                '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited']  . '+00:00' , ATOM_TIME)),
                                                '$location'           => xmlify($item['location']),
+                                               '$coord'              => xmlify($item['coord']),
                                                '$type'               => 'text',
                                                '$verb'               => xmlify($verb),
                                                '$actobj'             => $actobj,
                                                        '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
                                                        '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited']  . '+00:00' , ATOM_TIME)),
                                                        '$location'           => xmlify($item['location']),
+                                                       '$coord'              => xmlify($item['coord']),
                                                        '$type'               => 'text',
                                                        '$verb'               => xmlify($verb),
                                                        '$actobj'             => $actobj,
                                                        '$content'       => xmlify($item['body']),
                                                        '$alt'           => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']),
                                                        '$location'      => xmlify($item['location']),
+                                                       '$coord'         => xmlify($item['coord']),
                                                        '$type'          => 'text',
                                                        '$verb'          => xmlify($verb),
                                                        '$actobj'        => $actobj,
index fefef8ad6b4952e2cc36e9c9d3dcfcc2831d9e39..84176d293423d94e783d24d86eb6599676db274c 100644 (file)
@@ -229,7 +229,14 @@ function display_content(&$a) {
 
                        $like    = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
                        $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
-
+                       $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+                       $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
+                       if($coord) {
+                               if($location)
+                                       $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+                               else
+                                       $location = '<span class="smalltext">' . $coord . '</span>';
+                       }
 
                        $o .= replace_macros($template,array(
                                '$id' => $item['item_id'],
@@ -242,7 +249,7 @@ function display_content(&$a) {
                                '$body' => bbcode($item['body']),
                                '$ago' => relative_date($item['created']),
                                '$lock' => $lock,
-                               '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
+                               '$location' => $location,
                                '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
                                '$owner_url' => $owner_url,
                                '$owner_photo' => $owner_photo,
index 39865cdafa47cc9a96a6622fa9f291559b829aad..4ebb1e978157edb0d6b06822f033a9cd72539904 100644 (file)
@@ -57,6 +57,7 @@ function item_post(&$a) {
        $title             = notags(trim($_POST['title']));
        $body              = escape_tags(trim($_POST['body']));
        $location          = notags(trim($_POST['location']));
+       $coord             = notags(trim($_POST['coord']));
        $verb              = notags(trim($_POST['verb']));
 
        if(! strlen($body)) {
@@ -128,8 +129,8 @@ function item_post(&$a) {
 
        $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, 
                `author-name`, `author-link`, `author-avatar`, `created`,
-               `edited`, `changed`, `uri`, `title`, `body`, `location`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
-               VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+               `edited`, `changed`, `uri`, `title`, `body`, `location`, `coord`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
+               VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
                intval($profile_uid),
                dbesc($post_type),
                intval($wall),
@@ -148,6 +149,7 @@ function item_post(&$a) {
                dbesc($title),
                dbesc($body),
                dbesc($location),
+               dbesc($coord),
                dbesc($verb),
                dbesc($str_contact_allow),
                dbesc($str_group_allow),
index 3a747eac942c2f68635387e8351998a92929bc18..97a82a705c8a5ae12d5a1cec873ab1590f38f04c 100644 (file)
@@ -28,9 +28,14 @@ function network_content(&$a, $update = 0) {
                }
                $_SESSION['return_url'] = $a->cmd;
 
+               $geotag = (($a->user['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
+
                $tpl = load_view_file('view/jot-header.tpl');
        
-               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+               $a->page['htmlhead'] .= replace_macros($tpl, array(
+                       '$baseurl' => $a->get_baseurl(),
+                       '$geotag' => $geotag
+               ));
 
                require_once('view/acl_selectors.php');
 
@@ -272,6 +277,14 @@ function network_content(&$a, $update = 0) {
                        $like    = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
                        $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
 
+                       $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+                       $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
+                       if($coord) {
+                               if($location)
+                                       $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+                               else
+                                       $location = '<span class="smalltext">' . $coord . '</span>';
+                       }
 
                        // Build the HTML
 
@@ -286,7 +299,7 @@ function network_content(&$a, $update = 0) {
                                '$body' => bbcode($item['body']),
                                '$ago' => relative_date($item['created']),
                                '$lock' => $lock,
-                               '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
+                               '$location' => $location,
                                '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
                                '$owner_url' => $owner_url,
                                '$owner_photo' => $owner_photo,
index 8fa25cdbf8f39eb470fc9816dcb31dcd2008881d..ed26237b6861d508fdcc4226174827c872fb0c20 100644 (file)
@@ -118,6 +118,8 @@ function profile_content(&$a, $update = 0) {
                }
        }
 
+       $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
+
        if(! $update) {
                if(x($_GET,'tab'))
                        $tab = notags(trim($_GET['tab']));
@@ -141,9 +143,17 @@ function profile_content(&$a, $update = 0) {
 
                $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false);
                if(can_write_wall($a,$a->profile['profile_uid'])) {
+
+
+                       $geotag = (($is_owner && $a->profile['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
+
                        $tpl = load_view_file('view/jot-header.tpl');
        
-                       $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+                       $a->page['htmlhead'] .= replace_macros($tpl, array(
+                               '$baseurl' => $a->get_baseurl(),
+                               '$geotag'  => $geotag
+                       ));
+
                        require_once('view/acl_selectors.php');
 
                        $tpl = load_view_file("view/jot.tpl");
@@ -153,12 +163,12 @@ function profile_content(&$a, $update = 0) {
                                $lockstate = 'unlock';
                        $o .= replace_macros($tpl,array(
                                '$baseurl' => $a->get_baseurl(),
-                               '$defloc' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? $a->user['default-location'] : ''),
+                               '$defloc' => (($is_owner) ? $a->user['default-location'] : ''),
                                '$return_path' => $a->cmd,
-                               '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'),
+                               '$visitor' => (($is_owner) ? 'block' : 'none'),
                                '$lockstate' => $lockstate,
                                '$bang' => '',
-                               '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl($a->user, $celeb) : ''),
+                               '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
                                '$profile_uid' => $a->profile['profile_uid']
                        ));
                }
@@ -173,18 +183,15 @@ function profile_content(&$a, $update = 0) {
 
        }
 
-       // TODO alter registration and settings and profile to update contact table when names and  photos change.  
+       // Construct permissions
 
        // default permissions - anonymous user
 
        $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
 
-
-
-
        // Profile owner - everything is visible
 
-       if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid'])) {
+       if(is_owner) {
                $sql_extra = ''; 
                
                // Oh - while we're here... reset the Unseen messages
@@ -366,7 +373,14 @@ function profile_content(&$a, $update = 0) {
 
                        $like    = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
                        $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
-
+                       $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+                       $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
+                       if($coord) {
+                               if($location)
+                                       $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+                               else
+                                       $location = '<span class="smalltext">' . $coord . '</span>';
+                       }
 
                        $o .= replace_macros($template,array(
                                '$id' => $item['item_id'],
@@ -378,7 +392,7 @@ function profile_content(&$a, $update = 0) {
                                '$body' => bbcode($item['body']),
                                '$ago' => relative_date($item['created']),
                                '$lock' => $lock,
-                               '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
+                               '$location' => $location, 
                                '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
                                '$drop' => $drop,
                                '$like' => $like,
index b453fa8258f24d634fb38b052fdc2c32a7432bcb..863da44d5e8d494c10208caa3a6b60fd6effa8a3 100644 (file)
@@ -54,6 +54,7 @@ function settings_post(&$a) {
        $timezone         = notags(trim($_POST['timezone']));
        $defloc           = notags(trim($_POST['defloc']));
 
+       $allow_location   = (($_POST['allow_location'] == 1) ? 1: 0);
        $publish          = (($_POST['profile_in_directory'] == 1) ? 1: 0);
        $net_publish      = (($_POST['profile_in_netdirectory'] == 1) ? 1: 0);
        $old_visibility   = ((intval($_POST['visibility']) == 1) ? 1 : 0);
@@ -104,7 +105,7 @@ function settings_post(&$a) {
        $str_group_deny    = perms2str($_POST['group_deny']);
        $str_contact_deny  = perms2str($_POST['contact_deny']);
 
-       $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s',  `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `theme` = '%s'  WHERE `uid` = %d LIMIT 1",
+       $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s',  `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s'  WHERE `uid` = %d LIMIT 1",
                        dbesc($username),
                        dbesc($email),
                        dbesc($timezone),
@@ -115,6 +116,7 @@ function settings_post(&$a) {
                        intval($notify),
                        intval($page_flags),
                        dbesc($defloc),
+                       intval($allow_location),
                        dbesc($theme),
                        intval(local_user())
        );
@@ -208,6 +210,8 @@ function settings_content(&$a) {
        else
                $profile_in_net_dir = '';
 
+       $loc_checked = (($a->user['allow_location'] == 1)      ? " checked=\"checked\" " : "");
+
        $invisible = (((! $profile['publish']) && (! $profile['net-publish']))
                ? true : false);
 
@@ -259,6 +263,7 @@ function settings_content(&$a) {
                '$timezone' => $timezone,
                '$zoneselect' => select_timezone($timezone),
                '$defloc' => $defloc,
+               '$loc_checked' => $loc_checked,
                '$profile_in_dir' => $profile_in_dir,
                '$profile_in_net_dir' => $profile_in_net_dir,
                '$permissions' => t('Default Post Permissions'),
index da1d53e3945a8a6470adc20ea54b4b96b56b72fe..142119f4911ff4d38fe60820d02c7c35c5be3d8a 100644 (file)
@@ -4,7 +4,8 @@
       xmlns:at="http://purl.org/atompub/tombstones/1.0"
       xmlns:media="http://purl.org/syndication/atommedia"
       xmlns:dfrn="http://purl.org/macgirvin/dfrn/1.0" 
-      xmlns:as="http://activitystrea.ms/spec/1.0/" >
+      xmlns:as="http://activitystrea.ms/spec/1.0/"
+      xmlns:georss="http://www.georss.org/georss" >
 
   <id>$feed_id</id>
   <title>$feed_title</title>
index 401441e160a8e7125ccca65dcc81603e19d668f8..b26ba2e6948b5af0b2510b25c3208ea265104fc2 100644 (file)
@@ -19,6 +19,7 @@
                <content type="$type" >$content</content>
                <link rel="alternate" href="$alt" />
                <dfrn:location>$location</dfrn:location>
+               <georss:point>$coord</georss:point>
                <dfrn:comment-allow>$comment_allow</dfrn:comment-allow>
                <as:verb>$verb</as:verb>
                $actobj
index b07ffb1f60f64a260b743dcd7ae05d4fefdeb1e4..bdf0cb610621720be56b7ece7390ba102a06f4ff 100644 (file)
@@ -118,6 +118,7 @@ tinyMCE.init({
                }
        }
 
+       $geotag
 
 </script>
 
index 0dfad3f5e252acdabef50d3ed3bac0ad8c0b4fc6..363c4617f93a32504e765e59cf89f6d11afe5dfe 100644 (file)
@@ -11,6 +11,7 @@
                <input type="hidden" name="profile_uid" value="$profile_uid" />
                <input type="hidden" name="return" value="$return_path" />
                <input type="hidden" name="location" id="jot-location" value="$defloc" />
+               <input type="hidden" name="coord" id="jot-coord" value="" />
 
                <textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
 
index e06671d371b8e9541cb36e74b9688c6625df1fec..eeb683c7688a4b2c2aeca65aea1a0ca61d77d381 100644 (file)
@@ -34,6 +34,14 @@ $zoneselect
 </div>
 <div id="settings-defloc-end" ></div>
 
+<div id="settings-allowloc-wrapper" >
+<label id="settings-allowloc-label" for="settings-allowloc" >Use Browser Location: </label>
+<input type="checkbox" name="allow_location" id="settings-allowloc" value="1" $loc_checked />
+</div>
+<div id="settings-allowloc-end" ></div>
+
+
+
 
 <div id="settings-theme-select">
 <label id="settings-theme-label" for="theme-select" >Display Theme: </label>
index 237264df492e63ef669435f7fa011a93961283a4..066456e5463400d4536c038a944d9f943cd0c4ae 100644 (file)
@@ -105,7 +105,9 @@ blockquote:before {
        text-decoration: none;
        cursor: pointer;
 }
-
+.smalltext {
+       font-size: 0.7em;
+}
 #sysmsg {
        width: 600px;
        margin-bottom: 10px;
@@ -439,6 +441,7 @@ input#dfrn-url {
 #settings-email-end,
 #settings-nick-end,
 #settings-defloc-end,
+#settings-allowloc-end,
 #settings-timezone-end,
 #settings-theme-end,
 #settings-password-end,
@@ -456,6 +459,7 @@ input#dfrn-url {
 #settings-email-label,
 #settings-nick-label,
 #settings-defloc-label,
+#settings-allowloc-label,
 #settings-timezone-label,
 #settings-theme-label,
 #settings-password-label,
@@ -473,6 +477,7 @@ input#dfrn-url {
 #settings-email,
 #settings-nick,
 #settings-defloc,
+#settings-allowloc,
 #timezone-select,
 #theme-select,
 #settings-password,