]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/twitter.php
Merge pull request #445 from annando/new-worker
[friendica-addons.git] / twitter / twitter.php
index 7260910b047435f572312e7885eca7348c3751ce..21b6122ecfc4bc64bffea1e259b3524d28ade800 100644 (file)
@@ -60,6 +60,8 @@
  *     Requirements: PHP5, curl [Slinky library]
  */
 
+use Friendica\Core\Worker;
+
 require_once('include/enotify.php');
 require_once("include/socgraph.php");
 
@@ -181,17 +183,17 @@ function twitter_settings_post ($a,$post) {
                 * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair
                 * from the user configuration
                 */
-               del_pconfig(local_user(), 'twitter', 'consumerkey');
-               del_pconfig(local_user(), 'twitter', 'consumersecret');
-               del_pconfig(local_user(), 'twitter', 'oauthtoken');
-               del_pconfig(local_user(), 'twitter', 'oauthsecret');
-               del_pconfig(local_user(), 'twitter', 'post');
-               del_pconfig(local_user(), 'twitter', 'post_by_default');
-               del_pconfig(local_user(), 'twitter', 'lastid');
-               del_pconfig(local_user(), 'twitter', 'mirror_posts');
-               del_pconfig(local_user(), 'twitter', 'import');
-               del_pconfig(local_user(), 'twitter', 'create_user');
-               del_pconfig(local_user(), 'twitter', 'own_id');
+               PConfig::delete(local_user(), 'twitter', 'consumerkey');
+               PConfig::delete(local_user(), 'twitter', 'consumersecret');
+               PConfig::delete(local_user(), 'twitter', 'oauthtoken');
+               PConfig::delete(local_user(), 'twitter', 'oauthsecret');
+               PConfig::delete(local_user(), 'twitter', 'post');
+               PConfig::delete(local_user(), 'twitter', 'post_by_default');
+               PConfig::delete(local_user(), 'twitter', 'lastid');
+               PConfig::delete(local_user(), 'twitter', 'mirror_posts');
+               PConfig::delete(local_user(), 'twitter', 'import');
+               PConfig::delete(local_user(), 'twitter', 'create_user');
+               PConfig::delete(local_user(), 'twitter', 'own_id');
        } else {
        if (isset($_POST['twitter-pin'])) {
                //  if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
@@ -220,7 +222,7 @@ function twitter_settings_post ($a,$post) {
                PConfig::set(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
 
                if (!intval($_POST['twitter-mirror']))
-                       del_pconfig(local_user(),'twitter','lastid');
+                       PConfig::delete(local_user(),'twitter','lastid');
 
                info(t('Twitter settings updated.') . EOL);
        }}
@@ -232,7 +234,7 @@ function twitter_settings(&$a,&$s) {
        /***
         * 1) Check that we have global consumer key & secret
         * 2) If no OAuthtoken & stuff is present, generate button to get some
-        * 3) Checkbox for "Send public notices (140 chars only)
+        * 3) Checkbox for "Send public notices (280 chars only)
         */
        $ckey    = Config::get('twitter', 'consumerkey' );
        $csecret = Config::get('twitter', 'consumersecret' );
@@ -473,7 +475,7 @@ function twitter_post_hook(&$a,&$b) {
        logger('twitter post invoked');
 
 
-       load_pconfig($b['uid'], 'twitter');
+       PConfig::load($b['uid'], 'twitter');
 
        $ckey    = Config::get('twitter', 'consumerkey');
        $csecret = Config::get('twitter', 'consumersecret');
@@ -491,7 +493,7 @@ function twitter_post_hook(&$a,&$b) {
                require_once('include/bbcode.php');
                $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
 
-               $max_char = 140;
+               $max_char = 280;
                require_once("include/plaintext.php");
                $msgarr = plaintext($a, $b, $max_char, true, 8);
                $msg = $msgarr["text"];
@@ -646,7 +648,7 @@ function twitter_cron($a,$b) {
        if(count($r)) {
                foreach($r as $rr) {
                        logger('twitter: fetching for user '.$rr['uid']);
-                       proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int)$rr['uid']);
+                       Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int)$rr['uid']);
                }
        }
 
@@ -668,7 +670,7 @@ function twitter_cron($a,$b) {
                        }
 
                        logger('twitter: importing timeline from user '.$rr['uid']);
-                       proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 2, (int)$rr['uid']);
+                       Worker::add(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 2, (int)$rr['uid']);
 /*
                        // To-Do
                        // check for new contacts once a day
@@ -729,7 +731,7 @@ function twitter_prepare_body(&$a,&$b) {
                return;
 
        if ($b["preview"]) {
-               $max_char = 140;
+               $max_char = 280;
                require_once("include/plaintext.php");
                $item = $b["item"];
                $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
@@ -1850,7 +1852,7 @@ function twitter_fetch_own_contact($a, $uid) {
                if(count($r))
                        $contact_id = $r[0]["id"];
                else
-                       del_pconfig($uid, 'twitter', 'own_id');
+                       PConfig::delete($uid, 'twitter', 'own_id');
 
        }