]> git.mxchange.org Git - friendica.git/commitdiff
origin flag handling, and bug #137 - provide timezone conversion for events posted...
authorFriendika <info@friendika.com>
Mon, 17 Oct 2011 21:52:03 +0000 (14:52 -0700)
committerFriendika <info@friendika.com>
Mon, 17 Oct 2011 21:52:03 +0000 (14:52 -0700)
boot.php
include/bb2diaspora.php
include/event.php
include/items.php
mod/item.php
mod/like.php
mod/photos.php

index eb8bcc37733669fb83adbb8c1dc509cd644fe7a9..fec1870dfeda66dcbbb489cf177e5844801ae3ec 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -8,7 +8,7 @@ require_once("include/pgettext.php");
 require_once('include/nav.php');
 
 define ( 'FRIENDIKA_PLATFORM',     'Free Friendika');
-define ( 'FRIENDIKA_VERSION',      '2.3.1135' );
+define ( 'FRIENDIKA_VERSION',      '2.3.1137' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
 define ( 'DB_UPDATE_VERSION',      1097      );
 
index c72c78445340cfbf481f9826213a218a86f33cae..bdf278213cdd8f7c035c715433ee31a6e1b04be6 100644 (file)
@@ -11,12 +11,7 @@ function diaspora2bb($s) {
        $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
        $s = Markdown($s);
        $s = html2bbcode($s);
-
-//     $s = preg_replace('/\[url=(.+?)\<em\>(.+?)\]/ism','[url=$1_$2]',$s);
-//     $s = preg_replace('/\[url=(.+?)\<\/em\>(.+?)\]/ism','[url=$1_$2]',$s);
-
        return $s;
-
 }
 
 
@@ -185,6 +180,8 @@ function bb2diaspora($Text,$preserve_nl = false) {
 
 function format_event_diaspora($ev) {
 
+       $a = get_app();
+
        if(! ((is_array($ev)) && count($ev)))
                return '';
 
@@ -194,20 +191,20 @@ function format_event_diaspora($ev) {
 
        $o .= '**' . bb2diaspora($ev['desc']) .  '**' . "\n";
 
-       $o .= t('Starts:') . ' ' 
+       $o .= t('Starts:') . ' ' . '['
                . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', 
                        $ev['start'] , $bd_format ))
                        :  day_translate(datetime_convert('UTC', 'UTC', 
                        $ev['start'] , $bd_format)))
-               . "\n";
+               .  '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
 
        if(! $ev['nofinish'])
-               $o .= t('Finishes:') . ' ' 
+               $o .= t('Finishes:') . ' ' . '[' 
                        . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', 
                                $ev['finish'] , $bd_format ))
                                :  day_translate(datetime_convert('UTC', 'UTC', 
                                $ev['finish'] , $bd_format )))
-                       . "\n";
+                       . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
 
        if(strlen($ev['location']))
                $o .= t('Location:') . bb2diaspora($ev['location']) 
index 99f685d0bd9f2021c5ef39380c5a93453b460d2c..746422a137b5fe4b2bf2f8e2117a1b5b47c36b0b 100644 (file)
@@ -352,7 +352,7 @@ function event_store($arr) {
                $item_arr['visible']       = 1;
                $item_arr['verb']          = ACTIVITY_POST;
                $item_arr['object-type']   = ACTIVITY_OBJ_EVENT;
-
+               $item_arr['origin']        = ((intval($arr['cid']) == 0) ? 1 : 0);
                $item_arr['body']          = format_event_bbcode($event);
 
 
index 0c3c8b1d7aa8cd341c4dcc6beaaf9c51bad41b11..136dee90f649a6d07b76c430bd4786c86306ed18 100644 (file)
@@ -730,6 +730,7 @@ function item_store($arr,$force_parent = false) {
        $arr['tag']           = ((x($arr,'tag'))           ? notags(trim($arr['tag']))           : '');
        $arr['attach']        = ((x($arr,'attach'))        ? notags(trim($arr['attach']))        : '');
        $arr['app']           = ((x($arr,'app'))           ? notags(trim($arr['app']))           : '');
+       $arr['origin']        = ((x($arr,'origin'))        ? intval($arr['origin'])              : 0 );
        $arr['guid']          = ((x($arr,'guid'))          ? notags(trim($arr['guid']))          : get_guid());
 
        if($arr['parent-uri'] === $arr['uri']) {
index 9e6d33230a57100dc3936df422d9442293784efe..ab104735b97c47d1d6ead93fcb320d79f35f9908 100644 (file)
@@ -484,7 +484,12 @@ function item_post(&$a) {
                $verb = ACTIVITY_POST ;
 
        $gravity = (($parent) ? 6 : 0 );
+
+       // even if the post arrived via API we are considering that it 
+       // originated on this site by default for determining relayability.
+
+       $origin = ((x($_REQUEST,'origin')) ? intval($_REQUEST['origin']) : 1);
+       
        $notify_type = (($parent) ? 'comment-new' : 'wall-new' );
 
        $uri = item_new_uri($a->get_hostname(),$profile_uid);
@@ -525,6 +530,7 @@ function item_post(&$a) {
        $datarray['bookmark']      = intval($bookmark);
        $datarray['thr-parent']    = $thr_parent;
        $datarray['postopts']      = '';
+       $datarray['origin']        = $origin;
 
        /**
         * These fields are for the convenience of plugins...
@@ -566,8 +572,8 @@ function item_post(&$a) {
 
        $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, 
                `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, 
-               `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark` )
-               VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d )",
+               `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin` )
+               VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d )",
                dbesc($datarray['guid']),
                intval($datarray['uid']),
                dbesc($datarray['type']),
@@ -603,7 +609,8 @@ function item_post(&$a) {
                intval($datarray['private']),
                intval($datarray['pubmail']),
                dbesc($datarray['attach']),
-               intval($datarray['bookmark'])
+               intval($datarray['bookmark']),
+               intval($datarray['origin'])
        );
 
        $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
index 95bedcc20fed2a41a0fc2904e5b6b4fccd47e9e2..5c3dd323ec2d49eadeaa9b7dcabbf3d6fb4353ae 100644 (file)
@@ -154,7 +154,8 @@ EOT;
        $arr['uid'] = $owner_uid;
        $arr['contact-id'] = $contact['id'];
        $arr['type'] = 'activity';
-       $arr['wall'] = 1;
+       $arr['wall'] = $item['wall'];
+       $arr['origin'] = 1;
        $arr['gravity'] = GRAVITY_LIKE;
        $arr['parent'] = $item['id'];
        $arr['parent-uri'] = $item['uri'];
index 28416922197cd8e907996c62e8a7b4193fc8ca46..663d0a40cbaa8d1ec65cdddb3c61dd79bb0eb230 100644 (file)
@@ -348,6 +348,7 @@ function photos_post(&$a) {
                        $arr['deny_gid']      = $p[0]['deny_gid'];
                        $arr['last-child']    = 1;
                        $arr['visible']       = $visibility;
+                       $arr['origin']        = 1;
                        
                        $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' 
                                                . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' 
@@ -506,7 +507,7 @@ function photos_post(&$a) {
                                        $arr['target-type']   = ACTIVITY_OBJ_PHOTO;
                                        $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
-
+                                       $arr['origin']        = 1;
                                        $arr['body']          = '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]' . ' ' . t('was tagged in a') . ' ' . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('photo') . '[/url]' . ' ' . t('by') . ' ' . '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]' ;
                                        $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.jpg' . '[/img][/url]' . "\n" ;
 
@@ -695,6 +696,8 @@ function photos_post(&$a) {
        $arr['deny_gid']      = $str_group_deny;
        $arr['last-child']    = 1;
        $arr['visible']       = $visible;
+       $arr['origin']        = 1;
+
        $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']' 
                                . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]' 
                                . '[/url]';