]> git.mxchange.org Git - friendica-addons.git/blobdiff - pumpio/pumpio.php
fixing wrong translation
[friendica-addons.git] / pumpio / pumpio.php
index cb2ee000431c157ceed463ece56d55f98e58f132..95bc6b9f3ca37c9794e3f3e4e6457d1f9a05b62b 100644 (file)
@@ -68,8 +68,10 @@ function pumpio_registerclient(&$a, $host) {
        if ($application_name == "")
                $application_name = $a->get_hostname();
 
+       $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
+
        $params["type"] = "client_associate";
-       $params["contacts"] = $a->config['admin_email'];
+       $params["contacts"] = $adminlist[0];
        $params["application_type"] = "native";
        $params["application_name"] = $application_name;
        $params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
@@ -302,6 +304,7 @@ function pumpio_settings_post(&$a,&$b) {
                        set_pconfig(local_user(),'pumpio','mirror',false);
                        set_pconfig(local_user(),'pumpio','post_by_default',false);
                        set_pconfig(local_user(),'pumpio','lastdate', 0);
+                       set_pconfig(local_user(),'pumpio','last_id', '');
                } else {
                        // filtering the username if it is filled wrong
                        $user = $_POST['pumpio_user'];
@@ -433,9 +436,6 @@ function pumpio_send(&$a,&$b) {
 
                $title = trim($b['title']);
 
-               //if ($title != '')
-               //      $title = "<h4>".$title."</h4>";
-
                $content = bbcode($b['body'], false, false, 4);
 
                // Enhance the way, videos are displayed
@@ -502,6 +502,10 @@ function pumpio_send(&$a,&$b) {
                $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
 
                if($success) {
+
+                       if ($user->generator->displayName)
+                               set_pconfig($b["uid"], "pumpio", "application_name", $user->generator->displayName);
+
                        $post_id = $user->object->id;
                        logger('pumpio_send '.$username.': success '.$post_id);
                        if($post_id AND $iscomment) {
@@ -599,8 +603,7 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "") {
        }
 }
 
-
-function pumpio_cron(&$a,$b) {
+function pumpio_sync(&$a) {
        $last = get_config('pumpio','last_poll');
 
        $poll_interval = intval(get_config('pumpio','poll_interval'));
@@ -663,6 +666,11 @@ function pumpio_cron(&$a,$b) {
        set_config('pumpio','last_poll', time());
 }
 
+function pumpio_cron(&$a,$b) {
+       //pumpio_sync($a);
+       proc_run("php","addon/pumpio/pumpio_sync.php");
+}
+
 function pumpio_fetchtimeline(&$a, $uid) {
        $ckey    = get_pconfig($uid, 'pumpio', 'consumer_key');
        $csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
@@ -672,8 +680,12 @@ function pumpio_fetchtimeline(&$a, $uid) {
        $hostname = get_pconfig($uid, 'pumpio','host');
        $username = get_pconfig($uid, "pumpio", "user");
 
-       $application_name  = get_config('pumpio', 'application_name');
-
+       //  get the application name for the pump.io app
+       //  1st try personal config, then system config and fallback to the
+       //  hostname of the node if neither one is set.
+       $application_name  = get_pconfig( $uid, 'pumpio', 'application_name');
+       if ($application_name == "")
+               $application_name  = get_config('pumpio', 'application_name');
        if ($application_name == "")
                $application_name = $a->get_hostname();
 
@@ -731,7 +743,7 @@ function pumpio_fetchtimeline(&$a, $uid) {
                                        if ($receiver->id == "http://activityschema.org/collection/public")
                                                $public = true;
 
-                       if ($public AND !strstr($post->generator->displayName, $application_name)) {
+                       if ($public AND !stristr($post->generator->displayName, $application_name)) {
                                require_once('include/html2bbcode.php');
 
                                $_SESSION["authenticated"] = true;
@@ -1130,6 +1142,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
                                $public = true;
 
        $postarray = array();
+        $postarray['network'] = NETWORK_PUMPIO;
        $postarray['gravity'] = 0;
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
@@ -1227,6 +1240,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
                        $postarray['body'] = "[share author='".$post->object->author->displayName.
                                        "' profile='".$post->object->author->url.
                                        "' avatar='".$post->object->author->image->url.
+                                       "' posted='".datetime_convert('UTC','UTC',$post->object->created).
                                        "' link='".$post->links->self->href."']".$postarray['body']."[/share]";
                } else {
                        // Let shares look like wall-to-wall posts
@@ -1240,6 +1254,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
                return false;
 
        $top_item = item_store($postarray);
+       $postarray["id"] = $top_item;
 
        if (($top_item == 0) AND ($post->verb == "update")) {
                $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s' , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",