From 5360f08f4295f2306d815a7659fbdff94fda01a3 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan Error fetching token. Please try again. Error fetching token. Please try again. Error fetching user profile. Please clear the configuration and try again."
+" You have two ways to connect to App.net. First way: Register an application at https://account.app.net/developer/apps/ and enter "
+"Client ID and Client Secret. "
+msgstr ""
+
+#: appnet.php:167
+#, php-format
+msgid "Use '%s' as Redirect URI "
+msgstr ""
+
+#: appnet.php:169
+msgid "Client ID"
+msgstr ""
+
+#: appnet.php:173
+msgid "Client Secret"
+msgstr ""
+
+#: appnet.php:177
+msgid ""
+" Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "
+msgstr ""
+
+#: appnet.php:178
+msgid ""
+"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
+"'Messages'. Error fetching token. Please try again. Chyba v přenesení tokenu. Prosím zkuste to znovu. Error fetching user profile. Please clear the configuration and try "
+"again. Chyba v přenesení uživatelského profilu. Prosím zkuste smazat konfiguraci a zkusit to znovu. You have two ways to connect to App.net. Máte nyní dvě možnosti jak se připojit k App.net. First way: Register an application at https://account.app.net/developer/apps/"
+" and enter Client ID and Client Secret. "
+msgstr " První možnost: Registrovat svou žádost na https://account.app.net/developer/apps/ a zadat Client ID and Client Secret. "
+
+#: appnet.php:167
+#, php-format
+msgid "Use '%s' as Redirect URI "
+msgstr "Použít '%s' jako URI pro přesměrování "
+
+#: appnet.php:169
+msgid "Client ID"
+msgstr "Client ID"
+
+#: appnet.php:173
+msgid "Client Secret"
+msgstr "Client Secret"
+
+#: appnet.php:177
+msgid ""
+" Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "
+msgstr " Druhá možnost: vložit token do http://dev-lite.jonathonduerig.com/. "
+
+#: appnet.php:178
+msgid ""
+"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
+"'Messages'.
'.t("return to the connector page").'';
+
+ return($o);
+}
+
+function appnet_jot_nets(&$a,&$b) {
+ if(! local_user())
+ return;
+
+ $post = get_pconfig(local_user(),'appnet','post');
+ if(intval($post) == 1) {
+ $defpost = get_pconfig(local_user(),'appnet','post_by_default');
+ $selected = ((intval($defpost) == 1) ? ' checked="checked" ' : '');
+ $b .= '
'. t('App.net Import/Export').'
';
+ $s .= '';
+ $s .= '';
+}
+
+function appnet_settings_post(&$a,&$b) {
+
+ if(x($_POST,'appnet-submit')) {
+
+ if (isset($_POST['appnet-disconnect'])) {
+ del_pconfig(local_user(), 'appnet', 'clientsecret');
+ del_pconfig(local_user(), 'appnet', 'clientid');
+ del_pconfig(local_user(), 'appnet', 'token');
+ del_pconfig(local_user(), 'appnet', 'post');
+ del_pconfig(local_user(), 'appnet', 'post_by_default');
+ del_pconfig(local_user(), 'appnet', 'import');
+ }
+
+ if (isset($_POST["clientsecret"]))
+ set_pconfig(local_user(),'appnet','clientsecret', $_POST['clientsecret']);
+
+ if (isset($_POST["clientid"]))
+ set_pconfig(local_user(),'appnet','clientid', $_POST['clientid']);
+
+ if (isset($_POST["token"]) && ($_POST["token"] != ""))
+ set_pconfig(local_user(),'appnet','token', $_POST['token']);
+
+ set_pconfig(local_user(), 'appnet', 'post', intval($_POST['appnet']));
+ set_pconfig(local_user(), 'appnet', 'post_by_default', intval($_POST['appnet_bydefault']));
+ set_pconfig(local_user(), 'appnet', 'import', intval($_POST['appnet_import']));
+ }
+}
+
+function appnet_post_local(&$a,&$b) {
+ if($b['edit'])
+ return;
+
+ if((local_user()) && (local_user() == $b['uid']) && (!$b['private']) && (!$b['parent'])) {
+ $appnet_post = intval(get_pconfig(local_user(),'appnet','post'));
+ $appnet_enable = (($appnet_post && x($_REQUEST,'appnet_enable')) ? intval($_REQUEST['appnet_enable']) : 0);
+
+ // if API is used, default to the chosen settings
+ if($b['api_source'] && intval(get_pconfig(local_user(),'appnet','post_by_default')))
+ $appnet_enable = 1;
+
+ if(! $appnet_enable)
+ return;
+
+ if(strlen($b['postopts']))
+ $b['postopts'] .= ',';
+
+ $b['postopts'] .= 'appnet';
+ }
+}
+
+function appnet_create_entities($a, $b, $postdata) {
+ require_once("include/bbcode.php");
+ require_once("include/plaintext.php");
+
+ $bbcode = $b["body"];
+ $bbcode = bb_remove_share_information($bbcode, false, true);
+
+ // Change pure links in text to bbcode uris
+ $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
+
+ $URLSearchString = "^\[\]";
+
+ $bbcode = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'#$2',$bbcode);
+ $bbcode = preg_replace("/@\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'@$2',$bbcode);
+ $bbcode = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$bbcode);
+ $bbcode = preg_replace("/\[video\](.*?)\[\/video\]/ism",'[url=$1]$1[/url]',$bbcode);
+ $bbcode = preg_replace("/\[youtube\]https?:\/\/(.*?)\[\/youtube\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
+ $bbcode = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
+ '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
+ $bbcode = preg_replace("/\[vimeo\]https?:\/\/(.*?)\[\/vimeo\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
+ $bbcode = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
+ '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
+ //$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);
+
+ $bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $bbcode);
+
+
+ preg_match_all("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $bbcode, $urls, PREG_SET_ORDER);
+
+ $bbcode = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'$1',$bbcode);
+
+ $b["body"] = $bbcode;
+
+ // To-Do:
+ // Bilder
+ // https://alpha.app.net/heluecht/post/32424376
+ // https://alpha.app.net/heluecht/post/32424307
+
+ $plaintext = plaintext($a, $b, 0, false, 6);
+
+ $text = $plaintext["text"];
+
+ $start = 0;
+ $entities = array();
+
+ foreach ($urls AS $url) {
+ $lenurl = iconv_strlen($url[1], "UTF-8");
+ $len = iconv_strlen($url[2], "UTF-8");
+ $pos = iconv_strpos($text, $url[1], $start, "UTF-8");
+ $pre = iconv_substr($text, 0, $pos, "UTF-8");
+ $post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8");
+
+ $mid = $url[2];
+ $html = bbcode($mid, false, false, 6);
+ $mid = html2plain($html, 0, true);
+
+ $mid = trim(html_entity_decode($mid,ENT_QUOTES,'UTF-8'));
+
+ $text = $pre.$mid.$post;
+
+ if ($mid != "")
+ $entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid);
+
+ $start = $pos + 1;
+ }
+
+ if (isset($postdata["url"]) && isset($postdata["title"]) && ($postdata["type"] != "photo")) {
+ $postdata["title"] = shortenmsg($postdata["title"], 90);
+ $max = 256 - strlen($postdata["title"]);
+ $text = shortenmsg($text, $max);
+ $text .= "\n[".$postdata["title"]."](".$postdata["url"].")";
+ } elseif (isset($postdata["url"]) && ($postdata["type"] != "photo")) {
+ $postdata["url"] = short_link($postdata["url"]);
+ $max = 240;
+ $text = shortenmsg($text, $max);
+ $text .= " [".$postdata["url"]."](".$postdata["url"].")";
+ } else {
+ $max = 256;
+ $text = shortenmsg($text, $max);
+ }
+
+ if (iconv_strlen($text, "UTF-8") < $max)
+ $max = iconv_strlen($text, "UTF-8");
+
+ krsort($entities);
+ foreach ($entities AS $entity) {
+ //if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) {
+ if (($entity["pos"] + $entity["len"]) <= $max) {
+ $pre = iconv_substr($text, 0, $entity["pos"], "UTF-8");
+ $post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8");
+
+ $text = $pre."[".$entity["text"]."](".$entity["url"].")".$post;
+ }
+ }
+
+
+ return($text);
+}
+
+function appnet_send(&$a,&$b) {
+
+ logger('appnet_send: invoked for post '.$b['id']." ".$b['app']);
+
+ if (!get_pconfig($b["uid"],'appnet','import')) {
+ if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
+ return;
+ }
+
+ if($b['parent'] != $b['id']) {
+ logger("appnet_send: parameter ".print_r($b, true), LOGGER_DATA);
+
+ // Looking if its a reply to an app.net post
+ if ((substr($b["parent-uri"], 0, 5) != "adn::") && (substr($b["extid"], 0, 5) != "adn::") && (substr($b["thr-parent"], 0, 5) != "adn::")) {
+ logger("appnet_send: no app.net post ".$b["parent"]);
+ return;
+ }
+
+ $r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
+ dbesc($b["thr-parent"]),
+ intval($b["uid"]));
+
+ if(!count($r)) {
+ logger("appnet_send: no parent found ".$b["thr-parent"]);
+ return;
+ } else {
+ $iscomment = true;
+ $orig_post = $r[0];
+ }
+
+ $nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1", $orig_post["author-link"]);
+ $nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
+ $nicknameplain = "@".$nicknameplain;
+
+ logger("appnet_send: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
+ if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false))
+ $b["body"] = $nickname." ".$b["body"];
+
+ logger("appnet_send: parent found ".print_r($orig_post, true), LOGGER_DATA);
+ } else {
+ $iscomment = false;
+
+ if($b['private'] || !strstr($b['postopts'],'appnet'))
+ return;
+ }
+
+ if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
+ appnet_action($a, $b["uid"], substr($orig_post["uri"], 5), "delete");
+
+ if($b['verb'] == ACTIVITY_LIKE) {
+ logger("appnet_send: ".print_r($b, true), LOGGER_DEBUG);
+ logger("appnet_send: parameter 2 ".substr($b["thr-parent"], 5), LOGGER_DEBUG);
+ if ($b['deleted'])
+ appnet_action($a, $b["uid"], substr($b["thr-parent"], 5), "unlike");
+ else
+ appnet_action($a, $b["uid"], substr($b["thr-parent"], 5), "like");
+ return;
+ }
+
+ if($b['deleted'] || ($b['created'] !== $b['edited']))
+ return;
+
+ $token = get_pconfig($b['uid'],'appnet','token');
+
+ if($token) {
+
+ // If it's a repeated message from app.net then do a native repost and exit
+ if (appnet_is_repost($a, $b['uid'], $b['body']))
+ return;
+
+
+ require_once 'addon/appnet/AppDotNet.php';
+
+ $clientId = get_pconfig($b["uid"],'appnet','clientid');
+ $clientSecret = get_pconfig($b["uid"],'appnet','clientsecret');
+
+ $app = new AppDotNet($clientId, $clientSecret);
+ $app->setAccessToken($token);
+
+ $data = array();
+
+ require_once("include/plaintext.php");
+ require_once("include/network.php");
+
+ $post = plaintext($a, $b, 256, false, 6);
+ logger("appnet_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
+
+ if (isset($post["image"])) {
+ $img_str = fetch_url($post['image'],true, $redirects, 10);
+ $tempfile = tempnam(get_temppath(), "cache");
+ file_put_contents($tempfile, $img_str);
+
+ try {
+ $photoFile = $app->createFile($tempfile, array(type => "com.github.jdolitsky.appdotnetphp.photo"));
+
+ $data["annotations"][] = array(
+ "type" => "net.app.core.oembed",
+ "value" => array(
+ "+net.app.core.file" => array(
+ "file_id" => $photoFile["id"],
+ "file_token" => $photoFile["file_token"],
+ "format" => "oembed")
+ )
+ );
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_send: Error creating file ".appnet_error($e->getMessage()));
+ }
+
+ unlink($tempfile);
+ }
+
+ // Adding a link to the original post, if it is a root post
+ if($b['parent'] == $b['id'])
+ $data["annotations"][] = array(
+ "type" => "net.app.core.crosspost",
+ "value" => array("canonical_url" => $b["plink"])
+ );
+
+ // Adding the original post
+ $attached_data = get_attached_data($b["body"]);
+ $attached_data["post-uri"] = $b["uri"];
+ $attached_data["post-title"] = $b["title"];
+ $attached_data["post-body"] = substr($b["body"], 0, 4000); // To-Do: Better shortening
+ $attached_data["post-tag"] = $b["tag"];
+ $attached_data["author-name"] = $b["author-name"];
+ $attached_data["author-link"] = $b["author-link"];
+ $attached_data["author-avatar"] = $b["author-avatar"];
+
+ $data["annotations"][] = array(
+ "type" => "com.friendica.post",
+ "value" => $attached_data
+ );
+
+ if (isset($post["url"]) && !isset($post["title"]) && ($post["type"] != "photo")) {
+ $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $post["url"]);
+ $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
+
+ if (strlen($display_url) > 26)
+ $display_url = substr($display_url, 0, 25)."…";
+
+ $post["title"] = $display_url;
+ }
+
+ $text = appnet_create_entities($a, $b, $post);
+
+ $data["entities"]["parse_markdown_links"] = true;
+
+ if ($iscomment)
+ $data["reply_to"] = substr($orig_post["uri"], 5);
+
+ try {
+ logger("appnet_send: sending message ".$b["id"]." ".$text." ".print_r($data, true), LOGGER_DEBUG);
+ $ret = $app->createPost($text, $data);
+ logger("appnet_send: send message ".$b["id"]." result: ".print_r($ret, true), LOGGER_DEBUG);
+ if ($iscomment) {
+ logger('appnet_send: Update extid '.$ret["id"]." for post id ".$b['id']);
+ q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
+ dbesc("adn::".$ret["id"]),
+ intval($b['id'])
+ );
+ }
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_send: Error sending message ".$b["id"]." ".appnet_error($e->getMessage()));
+ }
+ }
+}
+
+function appnet_action($a, $uid, $pid, $action) {
+ require_once 'addon/appnet/AppDotNet.php';
+
+ $token = get_pconfig($uid,'appnet','token');
+ $clientId = get_pconfig($uid,'appnet','clientid');
+ $clientSecret = get_pconfig($uid,'appnet','clientsecret');
+
+ $app = new AppDotNet($clientId, $clientSecret);
+ $app->setAccessToken($token);
+
+ logger("appnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
+
+ try {
+ switch ($action) {
+ case "delete":
+ $result = $app->deletePost($pid);
+ break;
+ case "like":
+ $result = $app->starPost($pid);
+ break;
+ case "unlike":
+ $result = $app->unstarPost($pid);
+ break;
+ }
+ logger("appnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_action: Error sending action ".$action." pid ".$pid." ".appnet_error($e->getMessage()), LOGGER_DEBUG);
+ }
+}
+
+function appnet_is_repost($a, $uid, $body) {
+ $body = trim($body);
+
+ // Skip if it isn't a pure repeated messages
+ // Does it start with a share?
+ if (strpos($body, "[share") > 0)
+ return(false);
+
+ // Does it end with a share?
+ if (strlen($body) > (strrpos($body, "[/share]") + 8))
+ return(false);
+
+ $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
+ // Skip if there is no shared message in there
+ if ($body == $attributes)
+ return(false);
+
+ $link = "";
+ preg_match("/link='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
+
+ preg_match('/link="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
+
+ $id = preg_replace("=https?://alpha.app.net/(.*)/post/(.*)=ism", "$2", $link);
+ if ($id == $link)
+ return(false);
+
+ logger('appnet_is_repost: Reposting id '.$id.' for user '.$uid, LOGGER_DEBUG);
+
+ require_once 'addon/appnet/AppDotNet.php';
+
+ $token = get_pconfig($uid,'appnet','token');
+ $clientId = get_pconfig($uid,'appnet','clientid');
+ $clientSecret = get_pconfig($uid,'appnet','clientsecret');
+
+ $app = new AppDotNet($clientId, $clientSecret);
+ $app->setAccessToken($token);
+
+ try {
+ $result = $app->repost($id);
+ logger('appnet_is_repost: result '.print_r($result, true), LOGGER_DEBUG);
+ return true;
+ }
+ catch (AppDotNetException $e) {
+ logger('appnet_is_repost: error doing repost '.appnet_error($e->getMessage()), LOGGER_DEBUG);
+ return false;
+ }
+}
+
+function appnet_fetchstream($a, $uid) {
+ require_once("addon/appnet/AppDotNet.php");
+ require_once('include/items.php');
+
+ $token = get_pconfig($uid,'appnet','token');
+ $clientId = get_pconfig($uid,'appnet','clientid');
+ $clientSecret = get_pconfig($uid,'appnet','clientsecret');
+
+ $app = new AppDotNet($clientId, $clientSecret);
+ $app->setAccessToken($token);
+
+ $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
+ intval($uid));
+
+ if(count($r))
+ $me = $r[0];
+ else {
+ logger("appnet_fetchstream: Own contact not found for user ".$uid, LOGGER_DEBUG);
+ return;
+ }
+
+ $user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
+ intval($uid)
+ );
+
+ if(count($user))
+ $user = $user[0];
+ else {
+ logger("appnet_fetchstream: Own user not found for user ".$uid, LOGGER_DEBUG);
+ return;
+ }
+
+ $ownid = get_pconfig($uid,'appnet','ownid');
+
+ // Fetch stream
+ $param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
+ "include_html" => false, "include_post_annotations" => true);
+
+ $lastid = get_pconfig($uid, 'appnet', 'laststreamid');
+
+ if ($lastid <> "")
+ $param["since_id"] = $lastid;
+
+ try {
+ $stream = $app->getUserStream($param);
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_fetchstream: Error fetching stream for user ".$uid." ".appnet_error($e->getMessage()));
+ return;
+ }
+
+ if (!is_array($stream))
+ $stream = array();
+
+ $stream = array_reverse($stream);
+ foreach ($stream AS $post) {
+ $postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, true);
+
+ $item = item_store($postarray);
+ $postarray["id"] = $item;
+
+ logger('appnet_fetchstream: User '.$uid.' posted stream item '.$item);
+
+ $lastid = $post["id"];
+
+ if (($item != 0) && ($postarray['contact-id'] != $me["id"]) && !function_exists("check_item_notification")) {
+ $r = q("SELECT `thread`.`iid` AS `parent` FROM `thread`
+ INNER JOIN `item` ON `thread`.`iid` = `item`.`parent` AND `thread`.`uid` = `item`.`uid`
+ WHERE `item`.`id` = %d AND `thread`.`mention` LIMIT 1", dbesc($item));
+
+ if (count($r)) {
+ require_once('include/enotify.php');
+ notification(array(
+ 'type' => NOTIFY_COMMENT,
+ 'notify_flags' => $user['notify-flags'],
+ 'language' => $user['language'],
+ 'to_name' => $user['username'],
+ 'to_email' => $user['email'],
+ 'uid' => $user['uid'],
+ 'item' => $postarray,
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
+ 'source_name' => $postarray['author-name'],
+ 'source_link' => $postarray['author-link'],
+ 'source_photo' => $postarray['author-avatar'],
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'item',
+ 'parent' => $r[0]["parent"],
+ ));
+ }
+ }
+ }
+
+ set_pconfig($uid, 'appnet', 'laststreamid', $lastid);
+
+ // Fetch mentions
+ $param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
+ "include_html" => false, "include_post_annotations" => true);
+
+ $lastid = get_pconfig($uid, 'appnet', 'lastmentionid');
+
+ if ($lastid <> "")
+ $param["since_id"] = $lastid;
+
+ try {
+ $mentions = $app->getUserMentions("me", $param);
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_fetchstream: Error fetching mentions for user ".$uid." ".appnet_error($e->getMessage()));
+ return;
+ }
+
+ if (!is_array($mentions))
+ $mentions = array();
+
+ $mentions = array_reverse($mentions);
+ foreach ($mentions AS $post) {
+ $postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
+
+ if (isset($postarray["id"])) {
+ $item = $postarray["id"];
+ $parent_id = $postarray['parent'];
+ } elseif (isset($postarray["body"])) {
+ $item = item_store($postarray);
+ $postarray["id"] = $item;
+
+ $parent_id = 0;
+ logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
+
+ if ($item && function_exists("check_item_notification"))
+ check_item_notification($item, $uid, NOTIFY_TAGSELF);
+
+ } else {
+ $item = 0;
+ $parent_id = 0;
+ }
+
+ // Fetch the parent and id
+ if (($parent_id == 0) && ($postarray['uri'] != "")) {
+ $r = q("SELECT `id`, `parent` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($postarray['uri']),
+ intval($uid)
+ );
+
+ if (count($r)) {
+ $item = $r[0]['id'];
+ $parent_id = $r[0]['parent'];
+ }
+ }
+
+ $lastid = $post["id"];
+
+ //if (($item != 0) && ($postarray['contact-id'] != $me["id"])) {
+ if (($item != 0) && !function_exists("check_item_notification")) {
+ require_once('include/enotify.php');
+ notification(array(
+ 'type' => NOTIFY_TAGSELF,
+ 'notify_flags' => $user['notify-flags'],
+ 'language' => $user['language'],
+ 'to_name' => $user['username'],
+ 'to_email' => $user['email'],
+ 'uid' => $user['uid'],
+ 'item' => $postarray,
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
+ 'source_name' => $postarray['author-name'],
+ 'source_link' => $postarray['author-link'],
+ 'source_photo' => $postarray['author-avatar'],
+ 'verb' => ACTIVITY_TAG,
+ 'otype' => 'item',
+ 'parent' => $parent_id,
+ ));
+ }
+ }
+
+ set_pconfig($uid, 'appnet', 'lastmentionid', $lastid);
+
+
+/* To-Do
+ $param = array("interaction_actions" => "star");
+ $interactions = $app->getMyInteractions($param);
+ foreach ($interactions AS $interaction)
+ appnet_dolike($a, $uid, $interaction);
+*/
+}
+
+function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true, $nodupcheck = false) {
+ require_once('include/items.php');
+
+ if ($post["machine_only"])
+ return;
+
+ if ($post["is_deleted"])
+ return;
+
+ $postarray = array();
+ $postarray['gravity'] = 0;
+ $postarray['uid'] = $uid;
+ $postarray['wall'] = 0;
+ $postarray['verb'] = ACTIVITY_POST;
+ $postarray['network'] = dbesc(NETWORK_APPNET);
+ if (is_array($post["repost_of"])) {
+ // You can't reply to reposts. So use the original id and thread-id
+ $postarray['uri'] = "adn::".$post["repost_of"]["id"];
+ $postarray['parent-uri'] = "adn::".$post["repost_of"]["thread_id"];
+ } else {
+ $postarray['uri'] = "adn::".$post["id"];
+ $postarray['parent-uri'] = "adn::".$post["thread_id"];
+ }
+
+ if (!$nodupcheck) {
+ $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($postarray['uri']),
+ intval($uid)
+ );
+
+ if (count($r))
+ return($r[0]);
+
+ $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($postarray['uri']),
+ intval($uid)
+ );
+
+ if (count($r))
+ return($r[0]);
+ }
+
+ if (isset($post["reply_to"]) && ($post["reply_to"] != "")) {
+ $postarray['thr-parent'] = "adn::".$post["reply_to"];
+
+ // Complete the thread (if the parent doesn't exists)
+ if ($threadcompletion) {
+ //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ // dbesc($postarray['thr-parent']),
+ // intval($uid)
+ // );
+ //if (!count($r)) {
+ logger("appnet_createpost: completing thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
+
+ require_once("addon/appnet/AppDotNet.php");
+
+ $token = get_pconfig($uid,'appnet','token');
+ $clientId = get_pconfig($uid,'appnet','clientid');
+ $clientSecret = get_pconfig($uid,'appnet','clientsecret');
+
+ $app = new AppDotNet($clientId, $clientSecret);
+ $app->setAccessToken($token);
+
+ $param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
+ "include_html" => false, "include_post_annotations" => true);
+ try {
+ $thread = $app->getPostReplies($post["thread_id"], $param);
+ }
+ catch (AppDotNetException $e) {
+ logger("appnet_createpost: Error fetching thread for user ".$uid." ".appnet_error($e->getMessage()));
+ }
+ $thread = array_reverse($thread);
+
+ logger("appnet_createpost: fetched ".count($thread)." items for thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
+
+ foreach ($thread AS $tpost) {
+ $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false);
+ $item = item_store($threadpost);
+ $threadpost["id"] = $item;
+
+ logger("appnet_createpost: stored post ".$post["id"]." thread ".$post["thread_id"]." in item ".$item, LOGGER_DEBUG);
+ }
+ //}
+ }
+ // Don't create accounts of people who just comment something
+ $createuser = false;
+
+ $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
+ } else {
+ $postarray['thr-parent'] = $postarray['uri'];
+ $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+ }
+
+ if (($post["user"]["id"] != $ownid) || ($postarray['thr-parent'] == $postarray['uri'])) {
+ $postarray['owner-name'] = $post["user"]["name"];
+ $postarray['owner-link'] = $post["user"]["canonical_url"];
+ $postarray['owner-avatar'] = $post["user"]["avatar_image"]["url"];
+ $postarray['contact-id'] = appnet_fetchcontact($a, $uid, $post["user"], $me, $createuser);
+ } else {
+ $postarray['owner-name'] = $me["name"];
+ $postarray['owner-link'] = $me["url"];
+ $postarray['owner-avatar'] = $me["thumb"];
+ $postarray['contact-id'] = $me["id"];
+ }
+
+ $links = array();
+
+ if (is_array($post["repost_of"])) {
+ $postarray['author-name'] = $post["repost_of"]["user"]["name"];
+ $postarray['author-link'] = $post["repost_of"]["user"]["canonical_url"];
+ $postarray['author-avatar'] = $post["repost_of"]["user"]["avatar_image"]["url"];
+
+ $content = $post["repost_of"];
+ } else {
+ $postarray['author-name'] = $postarray['owner-name'];
+ $postarray['author-link'] = $postarray['owner-link'];
+ $postarray['author-avatar'] = $postarray['owner-avatar'];
+
+ $content = $post;
+ }
+
+ $postarray['plink'] = $content["canonical_url"];
+
+ if (is_array($content["entities"])) {
+ $converted = appnet_expand_entities($a, $content["text"], $content["entities"]);
+ $postarray['body'] = $converted["body"];
+ $postarray['tag'] = $converted["tags"];
+ } else
+ $postarray['body'] = $content["text"];
+
+ if (sizeof($content["entities"]["links"]))
+ foreach($content["entities"]["links"] AS $link) {
+ $url = normalise_link($link["url"]);
+ $links[$url] = $link["url"];
+ }
+
+ /* if (sizeof($content["annotations"]))
+ foreach($content["annotations"] AS $annotation) {
+ if ($annotation[type] == "net.app.core.oembed") {
+ if (isset($annotation["value"]["embeddable_url"])) {
+ $url = normalise_link($annotation["value"]["embeddable_url"]);
+ if (isset($links[$url]))
+ unset($links[$url]);
+ }
+ } elseif ($annotation[type] == "com.friendica.post") {
+ //$links = array();
+ //if (isset($annotation["value"]["post-title"]))
+ // $postarray['title'] = $annotation["value"]["post-title"];
+
+ //if (isset($annotation["value"]["post-body"]))
+ // $postarray['body'] = $annotation["value"]["post-body"];
+
+ //if (isset($annotation["value"]["post-tag"]))
+ // $postarray['tag'] = $annotation["value"]["post-tag"];
+
+ if (isset($annotation["value"]["author-name"]))
+ $postarray['author-name'] = $annotation["value"]["author-name"];
+
+ if (isset($annotation["value"]["author-link"]))
+ $postarray['author-link'] = $annotation["value"]["author-link"];
+
+ if (isset($annotation["value"]["author-avatar"]))
+ $postarray['author-avatar'] = $annotation["value"]["author-avatar"];
+ }
+
+ } */
+
+ $page_info = "";
+
+ if (is_array($content["annotations"])) {
+ $photo = appnet_expand_annotations($a, $content["annotations"]);
+ if (($photo["large"] != "") && ($photo["url"] != ""))
+ $page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]";
+ elseif ($photo["url"] != "")
+ $page_info = "\n[img]".$photo["url"]."[/img]";
+
+ if ($photo["url"] != "")
+ $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
+
+ } else
+ $photo = array("url" => "", "large" => "");
+
+ if (sizeof($links)) {
+ $link = array_pop($links);
+ $url = str_replace(array('/', '.'), array('\/', '\.'), $link);
+
+ $page_info = add_page_info($link, false, $photo["url"]);
+
+ if (trim($page_info) != "") {
+ $removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
+ if (($removedlink == "") || strstr($postarray['body'], $removedlink))
+ $postarray['body'] = $removedlink;
+ }
+ }
+
+ $postarray['body'] .= $page_info;
+
+ $postarray['created'] = datetime_convert('UTC','UTC',$post["created_at"]);
+ $postarray['edited'] = datetime_convert('UTC','UTC',$post["created_at"]);
+
+ $postarray['app'] = $post["source"]["name"];
+
+ return($postarray);
+}
+
+function appnet_expand_entities($a, $body, $entities) {
+
+ if (!function_exists('substr_unicode')) {
+ function substr_unicode($str, $s, $l = null) {
+ return join("", array_slice(
+ preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
+ }
+ }
+
+ $tags_arr = array();
+ $replace = array();
+
+ foreach ($entities["mentions"] AS $mention) {
+ $url = "@[url=https://alpha.app.net/".rawurlencode($mention["name"])."]".$mention["name"]."[/url]";
+ $tags_arr["@".$mention["name"]] = $url;
+ $replace[$mention["pos"]] = array("pos"=> $mention["pos"], "len"=> $mention["len"], "replace"=> $url);
+ }
+
+ foreach ($entities["hashtags"] AS $hashtag) {
+ $url = "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag["name"])."]".$hashtag["name"]."[/url]";
+ $tags_arr["#".$hashtag["name"]] = $url;
+ $replace[$hashtag["pos"]] = array("pos"=> $hashtag["pos"], "len"=> $hashtag["len"], "replace"=> $url);
+ }
+
+ foreach ($entities["links"] AS $links) {
+ $url = "[url=".$links["url"]."]".$links["text"]."[/url]";
+ if (isset($links["amended_len"]) && ($links["amended_len"] > $links["len"]))
+ $replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["amended_len"], "replace"=> $url);
+ else
+ $replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
+ }
+
+
+ if (sizeof($replace)) {
+ krsort($replace);
+ foreach ($replace AS $entity) {
+ $pre = substr_unicode($body, 0, $entity["pos"]);
+ $post = substr_unicode($body, $entity["pos"] + $entity["len"]);
+ //$pre = iconv_substr($body, 0, $entity["pos"], "UTF-8");
+ //$post = iconv_substr($body, $entity["pos"] + $entity["len"], "UTF-8");
+
+ $body = $pre.$entity["replace"].$post;
+ }
+ }
+
+ return(array("body" => $body, "tags" => implode($tags_arr, ",")));
+}
+
+function appnet_expand_annotations($a, $annotations) {
+ $photo = array("url" => "", "large" => "");
+ foreach ($annotations AS $annotation) {
+ if (($annotation[type] == "net.app.core.oembed") &&
+ ($annotation["value"]["type"] == "photo")) {
+ if ($annotation["value"]["url"] != "")
+ $photo["url"] = $annotation["value"]["url"];
+
+ if ($annotation["value"]["thumbnail_large_url"] != "")
+ $photo["large"] = $annotation["value"]["thumbnail_large_url"];
+
+ //if (($annotation["value"]["thumbnail_large_url"] != "") && ($annotation["value"]["url"] != ""))
+ // $embedded = "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
+ //elseif ($annotation["value"]["url"] != "")
+ // $embedded = "\n[img]".$annotation["value"]["url"]."[/img]";
+ }
+ }
+ return $photo;
+}
+
+function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
+
+ update_gcontact(array("url" => $contact["canonical_url"], "generation" => 2,
+ "network" => NETWORK_APPNET, "photo" => $contact["avatar_image"]["url"],
+ "name" => $contact["name"], "nick" => $contact["username"],
+ "about" => $contact["description"]["text"], "hide" => true,
+ "addr" => $contact["username"]."@app.net"));
+
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
+ intval($uid), dbesc("adn::".$contact["id"]));
+
+ if(!count($r) && !$create_user)
+ return($me["id"]);
+
+ if ($contact["canonical_url"] == "")
+ return($me["id"]);
+
+ if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
+ logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
+ return(-1);
+ }
+
+ if(!count($r)) {
+
+ if ($contact["name"] == "")
+ $contact["name"] = $contact["username"];
+
+ if ($contact["username"] == "")
+ $contact["username"] = $contact["name"];
+
+ // create contact record
+ q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
+ `name`, `nick`, `photo`, `network`, `rel`, `priority`,
+ `about`, `writable`, `blocked`, `readonly`, `pending` )
+ VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, 0, 0, 0 ) ",
+ intval($uid),
+ dbesc(datetime_convert()),
+ dbesc($contact["canonical_url"]),
+ dbesc(normalise_link($contact["canonical_url"])),
+ dbesc($contact["username"]."@app.net"),
+ dbesc("adn::".$contact["id"]),
+ dbesc(''),
+ dbesc("adn::".$contact["id"]),
+ dbesc($contact["name"]),
+ dbesc($contact["username"]),
+ dbesc($contact["avatar_image"]["url"]),
+ dbesc(NETWORK_APPNET),
+ intval(CONTACT_IS_FRIEND),
+ intval(1),
+ dbesc($contact["description"]["text"]),
+ intval(1)
+ );
+
+ $r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc("adn::".$contact["id"]),
+ intval($uid)
+ );
+
+ if(! count($r))
+ return(false);
+
+ $contact_id = $r[0]['id'];
+
+ $g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
+ intval($uid)
+ );
+
+ if($g && intval($g[0]['def_gid'])) {
+ require_once('include/group.php');
+ group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
+ }
+
+ require_once("Photo.php");
+
+ $photos = import_profile_photo($contact["avatar_image"]["url"],$uid,$contact_id);
+
+ q("UPDATE `contact` SET `photo` = '%s',
+ `thumb` = '%s',
+ `micro` = '%s',
+ `name-date` = '%s',
+ `uri-date` = '%s',
+ `avatar-date` = '%s'
+ WHERE `id` = %d",
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($contact_id)
+ );
+ } else {
+ // update profile photos once every two weeks as we have no notification of when they change.
+
+ //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
+ $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
+
+ // check that we have all the photos, this has been known to fail on occasion
+
+ if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
+
+ logger("appnet_fetchcontact: Updating contact ".$contact["username"], LOGGER_DEBUG);
+
+ require_once("Photo.php");
+
+ $photos = import_profile_photo($contact["avatar_image"]["url"], $uid, $r[0]['id']);
+
+ q("UPDATE `contact` SET `photo` = '%s',
+ `thumb` = '%s',
+ `micro` = '%s',
+ `name-date` = '%s',
+ `uri-date` = '%s',
+ `avatar-date` = '%s',
+ `url` = '%s',
+ `nurl` = '%s',
+ `addr` = '%s',
+ `name` = '%s',
+ `nick` = '%s',
+ `about` = '%s'
+ WHERE `id` = %d",
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($contact["canonical_url"]),
+ dbesc(normalise_link($contact["canonical_url"])),
+ dbesc($contact["username"]."@app.net"),
+ dbesc($contact["name"]),
+ dbesc($contact["username"]),
+ dbesc($contact["description"]["text"]),
+ intval($r[0]['id'])
+ );
+ }
+ }
+
+ return($r[0]["id"]);
+}
+
+function appnet_prepare_body(&$a,&$b) {
+ if ($b["item"]["network"] != NETWORK_APPNET)
+ return;
+
+ if ($b["preview"]) {
+ $max_char = 256;
+ require_once("include/plaintext.php");
+ $item = $b["item"];
+ $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+
+ $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
+ dbesc($item["thr-parent"]),
+ intval(local_user()));
+
+ if(count($r)) {
+ $orig_post = $r[0];
+
+ $nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1", $orig_post["author-link"]);
+ $nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
+ $nicknameplain = "@".$nicknameplain;
+
+ if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
+ $item["body"] = $nickname." ".$item["body"];
+ }
+
+
+
+ $msgarr = plaintext($a, $item, $max_char, true);
+ $msg = appnet_create_entities($a, $item, $msgarr);
+
+ require_once("library/markdown.php");
+ $msg = Markdown($msg);
+
+ $b['html'] = $msg;
+ }
+}
+
+function appnet_cron($a,$b) {
+ $last = get_config('appnet','last_poll');
+
+ $poll_interval = intval(get_config('appnet','poll_interval'));
+ if(! $poll_interval)
+ $poll_interval = APPNET_DEFAULT_POLL_INTERVAL;
+
+ if($last) {
+ $next = $last + ($poll_interval * 60);
+ if($next > time()) {
+ logger('appnet_cron: poll intervall not reached');
+ return;
+ }
+ }
+ logger('appnet_cron: cron_start');
+
+ $abandon_days = intval(get_config('system','account_abandon_days'));
+ if ($abandon_days < 1)
+ $abandon_days = 0;
+
+ $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
+
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'appnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
+ if(count($r)) {
+ foreach($r as $rr) {
+ if ($abandon_days != 0) {
+ $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
+ if (!count($user)) {
+ logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
+ continue;
+ }
+ }
+
+ logger('appnet_cron: importing timeline from user '.$rr['uid']);
+ appnet_fetchstream($a, $rr["uid"]);
+ }
+ }
+
+ logger('appnet_cron: cron_end');
+
+ set_config('appnet','last_poll', time());
+}
+
+function appnet_error($msg) {
+ $msg = trim($msg);
+ $pos = strrpos($msg, "\r\n\r\n");
+
+ if (!$pos)
+ return($msg);
+
+ $msg = substr($msg, $pos + 4);
+
+ $error = json_decode($msg);
+
+ if ($error == NULL)
+ return($msg);
+
+ if (isset($error->meta->error_message))
+ return($error->meta->error_message);
+ else
+ return(print_r($error));
+}
diff --git a/appnet/lang/C/messages.po b/appnet/lang/C/messages.po
new file mode 100644
index 00000000..a6617de9
--- /dev/null
+++ b/appnet/lang/C/messages.po
@@ -0,0 +1,116 @@
+# ADDON appnet
+# Copyright (C)
+# This file is distributed under the same license as the Friendica appnet addon package.
+#
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-22 11:47+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME
Error fetching token. Please try again.
"] = "Chyba v přenesení tokenu. Prosím zkuste to znovu.
"; +$a->strings["return to the connector page"] = "návrat ke stránce konektor"; +$a->strings["Post to app.net"] = "Poslat příspěvek na app.net"; +$a->strings["App.net Export"] = "App.net Export"; +$a->strings["Currently connected to: "] = "V současné době připojen k:"; +$a->strings["Enable App.net Post Plugin"] = "Aktivovat App.net Post Plugin"; +$a->strings["Post to App.net by default"] = "Defaultně poslat na App.net"; +$a->strings["Import the remote timeline"] = "Importovat vzdálenou časovou osu"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Chyba v přenesení uživatelského profilu. Prosím zkuste smazat konfiguraci a zkusit to znovu.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Máte nyní dvě možnosti jak se připojit k App.net.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
První možnost: Registrovat svou žádost na https://account.app.net/developer/apps/ a zadat Client ID and Client Secret. "; +$a->strings["Use '%s' as Redirect URI
"] = "Použít '%s' jako URI pro přesměrování
"; +$a->strings["Client ID"] = "Client ID"; +$a->strings["Client Secret"] = "Client Secret"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Druhá možnost: vložit token do http://dev-lite.jonathonduerig.com/. "; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Nastavte tyto rámce: 'Základní', 'Stream', 'Psaní příspěvků, 'Veřejné zprávy', 'Zprávy'."; +$a->strings["Token"] = "Token"; +$a->strings["Sign in using App.net"] = "Přihlásit se s použitím App.net"; +$a->strings["Clear OAuth configuration"] = "Vymazat konfiguraci OAuth"; +$a->strings["Save Settings"] = "Uložit Nastavení"; diff --git a/appnet/lang/de/messages.po b/appnet/lang/de/messages.po new file mode 100644 index 00000000..6e8f7c88 --- /dev/null +++ b/appnet/lang/de/messages.po @@ -0,0 +1,118 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# bavatarError fetching token. Please try again.
" +msgstr "Fehler beim Holen des Tokens, bitte versuche es später noch einmal.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "zurück zur Connector Seite" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Nach app.net senden" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "App.net Export" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Momentan verbunden mit: " + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Veröffentlichungen bei App.net erlauben" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Standardmäßig bei App.net veröffentlichen" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importiere die entfernte Zeitleiste" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Beim Laden des Nutzerprofils ist ein Fehler aufgetreten. Bitte versuche es später noch einmal.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Du hast zwei Wege deinen friendica Account mit App.net zu verbinden.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Erster Weg: Registriere eine Anwendung unter https://account.app.net/developer/apps/ und wähle eine Client ID und ein Client Secret." + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Verwende '%s' als Redirect URI
" + +#: appnet.php:169 +msgid "Client ID" +msgstr "Client ID" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Client Secret" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
Zweiter Weg: Beantrage ein Token unter http://dev-lite.jonathonduerig.com/. " + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Verwende folgende Scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'." + +#: appnet.php:180 +msgid "Token" +msgstr "Token" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Per App.net anmelden" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "OAuth Konfiguration löschen" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Einstellungen speichern" diff --git a/appnet/lang/de/strings.php b/appnet/lang/de/strings.php new file mode 100644 index 00000000..da80cf7c --- /dev/null +++ b/appnet/lang/de/strings.php @@ -0,0 +1,29 @@ +strings["Permission denied."] = "Zugriff verweigert."; +$a->strings["You are now authenticated to app.net. "] = "Du bist nun auf app.net authentifiziert."; +$a->strings["Error fetching token. Please try again.
"] = "Fehler beim Holen des Tokens, bitte versuche es später noch einmal.
"; +$a->strings["return to the connector page"] = "zurück zur Connector Seite"; +$a->strings["Post to app.net"] = "Nach app.net senden"; +$a->strings["App.net Export"] = "App.net Export"; +$a->strings["Currently connected to: "] = "Momentan verbunden mit: "; +$a->strings["Enable App.net Post Plugin"] = "Veröffentlichungen bei App.net erlauben"; +$a->strings["Post to App.net by default"] = "Standardmäßig bei App.net veröffentlichen"; +$a->strings["Import the remote timeline"] = "Importiere die entfernte Zeitleiste"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Beim Laden des Nutzerprofils ist ein Fehler aufgetreten. Bitte versuche es später noch einmal.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Du hast zwei Wege deinen friendica Account mit App.net zu verbinden.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Erster Weg: Registriere eine Anwendung unter https://account.app.net/developer/apps/ und wähle eine Client ID und ein Client Secret."; +$a->strings["Use '%s' as Redirect URI
"] = "Verwende '%s' als Redirect URI
"; +$a->strings["Client ID"] = "Client ID"; +$a->strings["Client Secret"] = "Client Secret"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Zweiter Weg: Beantrage ein Token unter http://dev-lite.jonathonduerig.com/. "; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Verwende folgende Scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'."; +$a->strings["Token"] = "Token"; +$a->strings["Sign in using App.net"] = "Per App.net anmelden"; +$a->strings["Clear OAuth configuration"] = "OAuth Konfiguration löschen"; +$a->strings["Save Settings"] = "Einstellungen speichern"; diff --git a/appnet/lang/es/messages.po b/appnet/lang/es/messages.po new file mode 100644 index 00000000..a44089d7 --- /dev/null +++ b/appnet/lang/es/messages.po @@ -0,0 +1,118 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# Alberto Díaz TormoError fetching token. Please try again.
" +msgstr "Advertencia de error. Por favor inténtelo de nuevo.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "vuelva a pa página de conexón" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Publique en app.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "Exportar a app.net" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Actualmente conectado a:" + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Habilitar el plugin de publicación de App.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Publicar en App.net por defecto" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importar la línea de tiempo remota" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Advertencia de error de perfil. Por favor borre la configuración e inténtelo de nuevo.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Tiene dos formas de conectar a App.net.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Primera forma: Registrar una aplicación en https://account.app.net/developer/apps/ y seleccionar Client ID y Client Secret. " + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Use '%s' como Redirigir URI" + +#: appnet.php:169 +msgid "Client ID" +msgstr "ID de cliente" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Secreto de cliente" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
Segunda manera: traiga un símbolo a http://dev-lite.jonathonduerig.com/" + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Seleccione estas posibilidades: 'Básico', 'Continuo', 'Escribir entrada', 'Mensajes públicos', 'Mensajes'." + +#: appnet.php:180 +msgid "Token" +msgstr "Símbolo" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Regístrese usando App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Borre la configuración OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Guardar los ajustes" diff --git a/appnet/lang/es/strings.php b/appnet/lang/es/strings.php new file mode 100644 index 00000000..020c6f35 --- /dev/null +++ b/appnet/lang/es/strings.php @@ -0,0 +1,29 @@ +strings["Permission denied."] = "Permiso denegado"; +$a->strings["You are now authenticated to app.net. "] = "Ahora está autenticado en app.net."; +$a->strings["Error fetching token. Please try again.
"] = "Advertencia de error. Por favor inténtelo de nuevo.
"; +$a->strings["return to the connector page"] = "vuelva a pa página de conexón"; +$a->strings["Post to app.net"] = "Publique en app.net"; +$a->strings["App.net Export"] = "Exportar a app.net"; +$a->strings["Currently connected to: "] = "Actualmente conectado a:"; +$a->strings["Enable App.net Post Plugin"] = "Habilitar el plugin de publicación de App.net"; +$a->strings["Post to App.net by default"] = "Publicar en App.net por defecto"; +$a->strings["Import the remote timeline"] = "Importar la línea de tiempo remota"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Advertencia de error de perfil. Por favor borre la configuración e inténtelo de nuevo.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Tiene dos formas de conectar a App.net.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Primera forma: Registrar una aplicación en https://account.app.net/developer/apps/ y seleccionar Client ID y Client Secret. "; +$a->strings["Use '%s' as Redirect URI
"] = "Use '%s' como Redirigir URI"; +$a->strings["Client ID"] = "ID de cliente"; +$a->strings["Client Secret"] = "Secreto de cliente"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Segunda manera: traiga un símbolo a http://dev-lite.jonathonduerig.com/"; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Seleccione estas posibilidades: 'Básico', 'Continuo', 'Escribir entrada', 'Mensajes públicos', 'Mensajes'."; +$a->strings["Token"] = "Símbolo"; +$a->strings["Sign in using App.net"] = "Regístrese usando App.net"; +$a->strings["Clear OAuth configuration"] = "Borre la configuración OAuth"; +$a->strings["Save Settings"] = "Guardar los ajustes"; diff --git a/appnet/lang/fr/messages.po b/appnet/lang/fr/messages.po new file mode 100644 index 00000000..6f5f2997 --- /dev/null +++ b/appnet/lang/fr/messages.po @@ -0,0 +1,119 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# Hypolite PetovanError fetching token. Please try again.
" +msgstr "Impossible d'obtenir le jeton, merci de réessayer.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "revenir à la page du connecteur" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Publier sur app.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "Export App.net" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Actuellement connecté à :" + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Activer le plugin de publication app.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Publier sur App.net par défaut" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importer la timeline distante" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Impossible d'obtenir le profil utilisateur. Merci de réinitialiser la configuration et de réessayer.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Vous avez deux possibilités pour vous connecter à App.net.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Première méthode: Enregistrer une application sur App.net [en] et entrez l'ID Client et le Secret Client. " + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Utilisez '%s' pour l'URI de Redirection" + +#: appnet.php:169 +msgid "Client ID" +msgstr "ID Client" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Secret Client" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
Deuxième méthode: obtenez un jeton ur http://dev-lite.jonathonduerig.com/ [en]. " + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Cochez les \"scopes\" suivant: \"Basic\", \"Stream\", \"Write Post\", \"Public Messages\", \"Messages\"." + +#: appnet.php:180 +msgid "Token" +msgstr "Jeton" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Se connecter avec App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Effacer la configuration OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Sauvegarder les paramètres" diff --git a/appnet/lang/fr/strings.php b/appnet/lang/fr/strings.php new file mode 100644 index 00000000..ef9fc9e2 --- /dev/null +++ b/appnet/lang/fr/strings.php @@ -0,0 +1,29 @@ + 1);; +}} +; +$a->strings["Permission denied."] = "Autorisation refusée"; +$a->strings["You are now authenticated to app.net. "] = "Vous êtes maintenant authentifié sur app.net"; +$a->strings["Error fetching token. Please try again.
"] = "Impossible d'obtenir le jeton, merci de réessayer.
"; +$a->strings["return to the connector page"] = "revenir à la page du connecteur"; +$a->strings["Post to app.net"] = "Publier sur app.net"; +$a->strings["App.net Export"] = "Export App.net"; +$a->strings["Currently connected to: "] = "Actuellement connecté à :"; +$a->strings["Enable App.net Post Plugin"] = "Activer le plugin de publication app.net"; +$a->strings["Post to App.net by default"] = "Publier sur App.net par défaut"; +$a->strings["Import the remote timeline"] = "Importer la timeline distante"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Impossible d'obtenir le profil utilisateur. Merci de réinitialiser la configuration et de réessayer.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Vous avez deux possibilités pour vous connecter à App.net.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Première méthode: Enregistrer une application sur App.net [en] et entrez l'ID Client et le Secret Client. "; +$a->strings["Use '%s' as Redirect URI
"] = "Utilisez '%s' pour l'URI de Redirection"; +$a->strings["Client ID"] = "ID Client"; +$a->strings["Client Secret"] = "Secret Client"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Deuxième méthode: obtenez un jeton ur http://dev-lite.jonathonduerig.com/ [en]. "; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Cochez les \"scopes\" suivant: \"Basic\", \"Stream\", \"Write Post\", \"Public Messages\", \"Messages\"."; +$a->strings["Token"] = "Jeton"; +$a->strings["Sign in using App.net"] = "Se connecter avec App.net"; +$a->strings["Clear OAuth configuration"] = "Effacer la configuration OAuth"; +$a->strings["Save Settings"] = "Sauvegarder les paramètres"; diff --git a/appnet/lang/it/messages.po b/appnet/lang/it/messages.po new file mode 100644 index 00000000..17b933fe --- /dev/null +++ b/appnet/lang/it/messages.po @@ -0,0 +1,118 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# fabrixxmError fetching token. Please try again.
" +msgstr "Errore recuperando il token. Prova di nuovo
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "ritorna alla pagina del connettore" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Invia ad app.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "Esporta App.net" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Al momento connesso con:" + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Abilita il plugin di invio ad App.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Invia sempre ad App.net" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importa la timeline remota" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Errore recuperando il profilo utente. Svuota la configurazione e prova di nuovo.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Puoi collegarti ad App.net in due modi.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Registrare un'applicazione su https://account.app.net/developer/apps/ e inserire Client ID e Client Secret." + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Usa '%s' come Redirect URI
" + +#: appnet.php:169 +msgid "Client ID" +msgstr "Client ID" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Client Secret" + +#: appnet.php:177 +msgid "" +"Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
Oppure puoi recuperare un token su http://dev-lite.jonathonduerig.com/." + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Imposta gli ambiti 'Basic', 'Stream', 'Scrivi Post', 'Messaggi Pubblici', 'Messaggi'." + +#: appnet.php:180 +msgid "Token" +msgstr "Token" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Autenticati con App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Pulisci configurazione OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Salva Impostazioni" diff --git a/appnet/lang/it/strings.php b/appnet/lang/it/strings.php new file mode 100644 index 00000000..01c56524 --- /dev/null +++ b/appnet/lang/it/strings.php @@ -0,0 +1,29 @@ +strings["Permission denied."] = "Permesso negato."; +$a->strings["You are now authenticated to app.net. "] = "Sei autenticato su app.net"; +$a->strings["Error fetching token. Please try again.
"] = "Errore recuperando il token. Prova di nuovo
"; +$a->strings["return to the connector page"] = "ritorna alla pagina del connettore"; +$a->strings["Post to app.net"] = "Invia ad app.net"; +$a->strings["App.net Export"] = "Esporta App.net"; +$a->strings["Currently connected to: "] = "Al momento connesso con:"; +$a->strings["Enable App.net Post Plugin"] = "Abilita il plugin di invio ad App.net"; +$a->strings["Post to App.net by default"] = "Invia sempre ad App.net"; +$a->strings["Import the remote timeline"] = "Importa la timeline remota"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Errore recuperando il profilo utente. Svuota la configurazione e prova di nuovo.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Puoi collegarti ad App.net in due modi.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Registrare un'applicazione su https://account.app.net/developer/apps/ e inserire Client ID e Client Secret."; +$a->strings["Use '%s' as Redirect URI
"] = "Usa '%s' come Redirect URI
"; +$a->strings["Client ID"] = "Client ID"; +$a->strings["Client Secret"] = "Client Secret"; +$a->strings["Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Oppure puoi recuperare un token su http://dev-lite.jonathonduerig.com/."; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Imposta gli ambiti 'Basic', 'Stream', 'Scrivi Post', 'Messaggi Pubblici', 'Messaggi'."; +$a->strings["Token"] = "Token"; +$a->strings["Sign in using App.net"] = "Autenticati con App.net"; +$a->strings["Clear OAuth configuration"] = "Pulisci configurazione OAuth"; +$a->strings["Save Settings"] = "Salva Impostazioni"; diff --git a/appnet/lang/nl/messages.po b/appnet/lang/nl/messages.po new file mode 100644 index 00000000..74653c76 --- /dev/null +++ b/appnet/lang/nl/messages.po @@ -0,0 +1,118 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# Jeroen SError fetching token. Please try again.
" +msgstr "Fout tijdens token fetching. Probeer het nogmaals.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "ga terug naar de connector pagina" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Post naar app.net." + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "App.net Export" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Momenteel verbonden met:" + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "App.net Post Plugin inschakelen" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Naar App.net posten als standaard instellen" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "The tijdlijn op afstand importeren" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Fout tijdens het ophalen van gebruikersprofiel. Leeg de configuratie en probeer het opnieuw.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Er zijn twee manieren om met App.net te verbinden.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "" + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "" + +#: appnet.php:169 +msgid "Client ID" +msgstr "" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "" + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "" + +#: appnet.php:180 +msgid "Token" +msgstr "" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "" diff --git a/appnet/lang/nl/strings.php b/appnet/lang/nl/strings.php new file mode 100644 index 00000000..ba72e364 --- /dev/null +++ b/appnet/lang/nl/strings.php @@ -0,0 +1,29 @@ +strings["Permission denied."] = "Toegang geweigerd"; +$a->strings["You are now authenticated to app.net. "] = "Je bent nu aangemeld bij app.net."; +$a->strings["Error fetching token. Please try again.
"] = "Fout tijdens token fetching. Probeer het nogmaals.
"; +$a->strings["return to the connector page"] = "ga terug naar de connector pagina"; +$a->strings["Post to app.net"] = "Post naar app.net."; +$a->strings["App.net Export"] = "App.net Export"; +$a->strings["Currently connected to: "] = "Momenteel verbonden met:"; +$a->strings["Enable App.net Post Plugin"] = "App.net Post Plugin inschakelen"; +$a->strings["Post to App.net by default"] = "Naar App.net posten als standaard instellen"; +$a->strings["Import the remote timeline"] = "The tijdlijn op afstand importeren"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Fout tijdens het ophalen van gebruikersprofiel. Leeg de configuratie en probeer het opnieuw.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Er zijn twee manieren om met App.net te verbinden.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = ""; +$a->strings["Use '%s' as Redirect URI
"] = ""; +$a->strings["Client ID"] = ""; +$a->strings["Client Secret"] = ""; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = ""; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = ""; +$a->strings["Token"] = ""; +$a->strings["Sign in using App.net"] = ""; +$a->strings["Clear OAuth configuration"] = ""; +$a->strings["Save Settings"] = ""; diff --git a/appnet/lang/pt-br/messages.po b/appnet/lang/pt-br/messages.po new file mode 100644 index 00000000..c279c7dd --- /dev/null +++ b/appnet/lang/pt-br/messages.po @@ -0,0 +1,119 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# Beatriz VitalError fetching token. Please try again.
" +msgstr "Erro ocorrido na obtenção do token. Tente novamente." + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "Volte a página de conectores." + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Publicar no App.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "App.net exportar" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Atualmente conectado em: " + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Habilitar plug-in para publicar no App.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Publicar em App.net por padrão" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importar a linha do tempo remota" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Erro na obtenção do perfil do usuário. Confira as configurações e tente novamente." + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Você possui duas formas de conectar ao App.net
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
1º Método: Registre uma aplicação em https://account.app.net/developer/apps/ e entre o Client ID e Client Secret" + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Use '%s' como URI redirecionador
" + +#: appnet.php:169 +msgid "Client ID" +msgstr "Client ID" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Client Secret" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
2º Método: obtenha um token em http://dev-lite.jonathonduerig.com/. " + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Adicione valor as estas saídas: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'." + +#: appnet.php:180 +msgid "Token" +msgstr "Token" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Entre usando o App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Limpar configuração OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Salvar Configurações" diff --git a/appnet/lang/pt-br/strings.php b/appnet/lang/pt-br/strings.php new file mode 100644 index 00000000..b8e1112c --- /dev/null +++ b/appnet/lang/pt-br/strings.php @@ -0,0 +1,29 @@ + 1);; +}} +; +$a->strings["Permission denied."] = "Permissão negada."; +$a->strings["You are now authenticated to app.net. "] = "Você está autenticado no app.net."; +$a->strings["Error fetching token. Please try again.
"] = "Erro ocorrido na obtenção do token. Tente novamente."; +$a->strings["return to the connector page"] = "Volte a página de conectores."; +$a->strings["Post to app.net"] = "Publicar no App.net"; +$a->strings["App.net Export"] = "App.net exportar"; +$a->strings["Currently connected to: "] = "Atualmente conectado em: "; +$a->strings["Enable App.net Post Plugin"] = "Habilitar plug-in para publicar no App.net"; +$a->strings["Post to App.net by default"] = "Publicar em App.net por padrão"; +$a->strings["Import the remote timeline"] = "Importar a linha do tempo remota"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Erro na obtenção do perfil do usuário. Confira as configurações e tente novamente."; +$a->strings["You have two ways to connect to App.net.
"] = "Você possui duas formas de conectar ao App.net
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
1º Método: Registre uma aplicação em https://account.app.net/developer/apps/ e entre o Client ID e Client Secret"; +$a->strings["Use '%s' as Redirect URI
"] = "Use '%s' como URI redirecionador
"; +$a->strings["Client ID"] = "Client ID"; +$a->strings["Client Secret"] = "Client Secret"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
2º Método: obtenha um token em http://dev-lite.jonathonduerig.com/. "; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Adicione valor as estas saídas: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'."; +$a->strings["Token"] = "Token"; +$a->strings["Sign in using App.net"] = "Entre usando o App.net"; +$a->strings["Clear OAuth configuration"] = "Limpar configuração OAuth"; +$a->strings["Save Settings"] = "Salvar Configurações"; diff --git a/appnet/lang/ro/messages.po b/appnet/lang/ro/messages.po new file mode 100644 index 00000000..a9c5242f --- /dev/null +++ b/appnet/lang/ro/messages.po @@ -0,0 +1,117 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-22 11:47+0200\n" +"PO-Revision-Date: 2014-07-08 11:40+0000\n" +"Last-Translator: Arian - Cazare MuncitoriError fetching token. Please try again.
" +msgstr "Eroare la procesarea token-ului. Vă rugăm să reîncercați.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "revenire la pagina de conectare" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Postați pe App.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "Exportare pe App.net" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "Conectat curent la:" + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Activare Modul Postare pe App.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Postați implicit pe App.net" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Importare cronologie la distanță" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Eroare la procesarea profilului de utilizator. Vă rugăm să ștergeți configurarea şi apoi reîncercați.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "Aveți două modalități de a vă conecta la App.net.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Prima modalitate: Înregistrați o cerere pe https://account.app.net/developer/apps/ şi introduceți ID Client şi Cheia Secretă Client." + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Utilizați '%s' ca URI de Redirecţionare
" + +#: appnet.php:169 +msgid "Client ID" +msgstr "ID Client" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Cheia Secretă Client" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
A doua cale: autorizați un indicativ de acces token de pe http://dev-lite.jonathonduerig.com/ ." + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Stabiliți aceste scopuri: 'De Bază', 'Flux', 'Scriere Postare', 'Mesaje Publice', 'Mesaje'." + +#: appnet.php:180 +msgid "Token" +msgstr "Token" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Autentificați-vă utilizând App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Ștergeți configurările OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Salvare Configurări" diff --git a/appnet/lang/ro/strings.php b/appnet/lang/ro/strings.php new file mode 100644 index 00000000..fa8d139d --- /dev/null +++ b/appnet/lang/ro/strings.php @@ -0,0 +1,29 @@ +19)||(($n%100==0)&&($n!=0)))?2:1));; +}} +; +$a->strings["Permission denied."] = "Permisiune refuzată."; +$a->strings["You are now authenticated to app.net. "] = "Acum sunteți autentificat pe App.net."; +$a->strings["Error fetching token. Please try again.
"] = "Eroare la procesarea token-ului. Vă rugăm să reîncercați.
"; +$a->strings["return to the connector page"] = "revenire la pagina de conectare"; +$a->strings["Post to app.net"] = "Postați pe App.net"; +$a->strings["App.net Export"] = "Exportare pe App.net"; +$a->strings["Currently connected to: "] = "Conectat curent la:"; +$a->strings["Enable App.net Post Plugin"] = "Activare Modul Postare pe App.net"; +$a->strings["Post to App.net by default"] = "Postați implicit pe App.net"; +$a->strings["Import the remote timeline"] = "Importare cronologie la distanță"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Eroare la procesarea profilului de utilizator. Vă rugăm să ștergeți configurarea şi apoi reîncercați.
"; +$a->strings["You have two ways to connect to App.net.
"] = "Aveți două modalități de a vă conecta la App.net.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Prima modalitate: Înregistrați o cerere pe https://account.app.net/developer/apps/ şi introduceți ID Client şi Cheia Secretă Client."; +$a->strings["Use '%s' as Redirect URI
"] = "Utilizați '%s' ca URI de Redirecţionare
"; +$a->strings["Client ID"] = "ID Client"; +$a->strings["Client Secret"] = "Cheia Secretă Client"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
A doua cale: autorizați un indicativ de acces token de pe http://dev-lite.jonathonduerig.com/ ."; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Stabiliți aceste scopuri: 'De Bază', 'Flux', 'Scriere Postare', 'Mesaje Publice', 'Mesaje'."; +$a->strings["Token"] = "Token"; +$a->strings["Sign in using App.net"] = "Autentificați-vă utilizând App.net"; +$a->strings["Clear OAuth configuration"] = "Ștergeți configurările OAuth"; +$a->strings["Save Settings"] = "Salvare Configurări"; diff --git a/appnet/lang/ru/messages.po b/appnet/lang/ru/messages.po new file mode 100644 index 00000000..a5755caa --- /dev/null +++ b/appnet/lang/ru/messages.po @@ -0,0 +1,118 @@ +# ADDON appnet +# Copyright (C) +# This file is distributed under the same license as the Friendica appnet addon package. +# +# +# Translators: +# Stanislav N.Error fetching token. Please try again.
" +msgstr "Ошибка получения токена. Попробуйте еще раз.
" + +#: appnet.php:80 +msgid "return to the connector page" +msgstr "вернуться на страницу коннектора" + +#: appnet.php:94 +msgid "Post to app.net" +msgstr "Отправить на app.net" + +#: appnet.php:125 appnet.php:129 +msgid "App.net Export" +msgstr "Экспорт app.net" + +#: appnet.php:142 +msgid "Currently connected to: " +msgstr "В настоящее время соединены с: " + +#: appnet.php:144 +msgid "Enable App.net Post Plugin" +msgstr "Включить плагин App.net" + +#: appnet.php:149 +msgid "Post to App.net by default" +msgstr "Отправлять сообщения на App.net по-умолчанию" + +#: appnet.php:153 +msgid "Import the remote timeline" +msgstr "Импортировать удаленные сообщения" + +#: appnet.php:159 +msgid "" +"Error fetching user profile. Please clear the configuration and try " +"again.
" +msgstr "Ошибка при получении профиля пользователя. Сбросьте конфигурацию и попробуйте еще раз.
" + +#: appnet.php:164 +msgid "You have two ways to connect to App.net.
" +msgstr "У вас есть два способа соединения с App.net.
" + +#: appnet.php:166 +msgid "" +"First way: Register an application at https://account.app.net/developer/apps/" +" and enter Client ID and Client Secret. " +msgstr "
Первый способ: зарегистрируйте приложение на https://account.app.net/developer/apps/ и введите Client ID и Client Secret" + +#: appnet.php:167 +#, php-format +msgid "Use '%s' as Redirect URI
" +msgstr "Используйте '%s' как Redirect URI
" + +#: appnet.php:169 +msgid "Client ID" +msgstr "Client ID" + +#: appnet.php:173 +msgid "Client Secret" +msgstr "Client Secret" + +#: appnet.php:177 +msgid "" +"
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. " +msgstr "
Второй путь: получите токен на http://dev-lite.jonathonduerig.com/. " + +#: appnet.php:178 +msgid "" +"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', " +"'Messages'.
" +msgstr "Выберите области: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'." + +#: appnet.php:180 +msgid "Token" +msgstr "Токен" + +#: appnet.php:192 +msgid "Sign in using App.net" +msgstr "Войти через App.net" + +#: appnet.php:197 +msgid "Clear OAuth configuration" +msgstr "Удалить конфигурацию OAuth" + +#: appnet.php:204 +msgid "Save Settings" +msgstr "Сохранить настройки" diff --git a/appnet/lang/ru/strings.php b/appnet/lang/ru/strings.php new file mode 100644 index 00000000..c2d9b440 --- /dev/null +++ b/appnet/lang/ru/strings.php @@ -0,0 +1,29 @@ +=2 && $n%10<=4 && ($n%100<12 || $n%100>14) ? 1 : $n%10==0 || ($n%10>=5 && $n%10<=9) || ($n%100>=11 && $n%100<=14)? 2 : 3);; +}} +; +$a->strings["Permission denied."] = "Доступ запрещен."; +$a->strings["You are now authenticated to app.net. "] = "Вы аутентифицированы на app.net"; +$a->strings["Error fetching token. Please try again.
"] = "Ошибка получения токена. Попробуйте еще раз.
"; +$a->strings["return to the connector page"] = "вернуться на страницу коннектора"; +$a->strings["Post to app.net"] = "Отправить на app.net"; +$a->strings["App.net Export"] = "Экспорт app.net"; +$a->strings["Currently connected to: "] = "В настоящее время соединены с: "; +$a->strings["Enable App.net Post Plugin"] = "Включить плагин App.net"; +$a->strings["Post to App.net by default"] = "Отправлять сообщения на App.net по-умолчанию"; +$a->strings["Import the remote timeline"] = "Импортировать удаленные сообщения"; +$a->strings["Error fetching user profile. Please clear the configuration and try again.
"] = "Ошибка при получении профиля пользователя. Сбросьте конфигурацию и попробуйте еще раз.
"; +$a->strings["You have two ways to connect to App.net.
"] = "У вас есть два способа соединения с App.net.
"; +$a->strings["First way: Register an application at https://account.app.net/developer/apps/ and enter Client ID and Client Secret. "] = "
Первый способ: зарегистрируйте приложение на https://account.app.net/developer/apps/ и введите Client ID и Client Secret"; +$a->strings["Use '%s' as Redirect URI
"] = "Используйте '%s' как Redirect URI
"; +$a->strings["Client ID"] = "Client ID"; +$a->strings["Client Secret"] = "Client Secret"; +$a->strings["
Second way: fetch a token at http://dev-lite.jonathonduerig.com/. "] = "
Второй путь: получите токен на http://dev-lite.jonathonduerig.com/. "; +$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.
"] = "Выберите области: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'."; +$a->strings["Token"] = "Токен"; +$a->strings["Sign in using App.net"] = "Войти через App.net"; +$a->strings["Clear OAuth configuration"] = "Удалить конфигурацию OAuth"; +$a->strings["Save Settings"] = "Сохранить настройки"; diff --git a/appnet/templates/admin.tpl b/appnet/templates/admin.tpl new file mode 100644 index 00000000..a933f3d3 --- /dev/null +++ b/appnet/templates/admin.tpl @@ -0,0 +1,3 @@ +{{include file="field_input.tpl" field=$clientid}} +{{include file="field_input.tpl" field=$clientsecret}} + diff --git a/blackout/blackout.php b/blackout/blackout.php index 2693db5a..3678969e 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -36,10 +36,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -49,7 +49,6 @@ * THE SOFTWARE. */ -use Friendica\Core\Config; function blackout_install() { register_hook('page_header', 'addon/blackout/blackout.php', 'blackout_redirect'); @@ -68,9 +67,9 @@ function blackout_redirect ($a, $b) { return true; // else... - $mystart = Config::get('blackout','begindate'); - $myend = Config::get('blackout','enddate'); - $myurl = Config::get('blackout','url'); + $mystart = get_config('blackout','begindate'); + $myend = get_config('blackout','enddate'); + $myurl = get_config('blackout','url'); $now = time(); $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend); @@ -88,21 +87,21 @@ function blackout_redirect ($a, $b) { } function blackout_plugin_admin(&$a, &$o) { - $mystart = Config::get('blackout','begindate'); + $mystart = get_config('blackout','begindate'); if (! is_string($mystart)) { $mystart = "YYYY-MM-DD:hhmm"; } - $myend = Config::get('blackout','enddate'); + $myend = get_config('blackout','enddate'); if (! is_string($myend)) { $myend = "YYYY-MM-DD:hhmm"; } - $myurl = Config::get('blackout','url'); + $myurl = get_config('blackout','url'); if (! is_string($myurl)) { $myurl = "http://www.example.com"; } $t = get_markup_template( "admin.tpl", "addon/blackout/" ); - - $o = replace_macros($t, [ + + $o = replace_macros($t, array( '$submit' => t('Save Settings'), - '$rurl' => ["rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"], - '$startdate' => ["startdate", "Begin of the Blackout

".t('You can download public events from: ').$a->get_baseurl()."/cal/username/export/ical
"; + } elseif ($a->argc==4) { + // get the parameters from the request we just received + $username = $a->argv[1]; + $do = $a->argv[2]; + $format = $a->argv[3]; + // check that there is a user matching the requested profile + $r = q("SELECT uid FROM user WHERE nickname='".$username."' LIMIT 1;"); + if (count($r)) + { + $uid = $r[0]['uid']; + } else { + killme(); + } + // if we shall do anything other then export, end here + if (! $do == 'export' ) + killme(); + // check if the user allows us to share the profile + $enable = get_pconfig( $uid, 'cal', 'enable'); + if (! $enable == 1) { + info(t('The user does not export the calendar.')); + return; + } + // we are allowed to show events + // get the timezone the user is in + $r = q("SELECT timezone FROM user WHERE uid=".$uid." LIMIT 1;"); + if (count($r)) + $timezone = $r[0]['timezone']; + // does the user who requests happen to be the owner of the events + // requested? then show all of your events, otherwise only those that + // don't have limitations set in allow_cid and allow_gid + if (local_user() == $uid) { + $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `uid`=".$uid." and `cid`=0;"); + } else { + $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `allow_cid`='' and `allow_gid`='' and `uid`='".$uid."' and `cid`='0';"); + } + // we have the events that are available for the requestor + // now format the output according to the requested format + $res = cal_format_output($r, $format, $timezone); + if (! $res=='') + info($res); + } else { + // wrong number of parameters + killme(); + } + return $o; +} + +function cal_format_output ($r, $f, $tz) +{ + $res = t('This calendar format is not supported'); + switch ($f) + { + // format the exported data as a CSV file + case "csv": + header("Content-type: text/csv"); + $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL; + foreach ($r as $rr) { +// TODO the time / date entries don't include any information about the +// timezone the event is scheduled in :-/ + $tmp1 = strtotime($rr['start']); + $tmp2 = strtotime($rr['finish']); + $time_format = "%H:%M:%S"; + $date_format = "%Y-%m-%d"; + $o .= '"'.$rr['summary'].'", "'.strftime($date_format, $tmp1) . + '", "'.strftime($time_format, $tmp1).'", "'.$rr['desc'] . + '", "'.strftime($date_format, $tmp2) . + '", "'.strftime($time_format, $tmp2) . + '", "'.$rr['location'].'"' . PHP_EOL; + } + echo $o; + killme(); + + case "ical": + header("Content-type: text/ics"); + $o = 'BEGIN:VCALENDAR'. PHP_EOL + . 'VERSION:2.0' . PHP_EOL + . 'PRODID:-//friendica calendar export//0.1//EN' . PHP_EOL; +// TODO include timezone informations in cases were the time is not in UTC +// see http://tools.ietf.org/html/rfc2445#section-4.8.3 +// . 'BEGIN:VTIMEZONE' . PHP_EOL +// . 'TZID:' . $tz . PHP_EOL +// . 'END:VTIMEZONE' . PHP_EOL; +// TODO instead of PHP_EOL CRLF should be used for long entries +// but test your solution against http://icalvalid.cloudapp.net/ +// also long lines SHOULD be split at 75 characters length + foreach ($r as $rr) { + if ($rr['adjust'] == 1) { + $UTC = 'Z'; + } else { + $UTC = ''; + } + $o .= 'BEGIN:VEVENT' . PHP_EOL; + if ($rr[start]) { + $tmp = strtotime($rr['start']); + $dtformat = "%Y%m%dT%H%M%S".$UTC; + $o .= 'DTSTART:'.strftime($dtformat, $tmp).PHP_EOL; + } + if ($rr['finish']) { + $tmp = strtotime($rr['finish']); + $dtformat = "%Y%m%dT%H%M%S".$UTC; + $o .= 'DTEND:'.strftime($dtformat, $tmp).PHP_EOL; + } + if ($rr['summary']) + $tmp = $rr['summary']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'SUMMARY:' . $tmp . PHP_EOL; + if ($rr['desc']) + $tmp = $rr['desc']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'DESCRIPTION:' . $tmp . PHP_EOL; + if ($rr['location']) { + $tmp = $rr['location']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'LOCATION:' . $tmp . PHP_EOL; + } + $o .= 'END:VEVENT' . PHP_EOL; + } + $o .= 'END:VCALENDAR' . PHP_EOL; + echo $o; + killme(); + } + return $res; +} + +function cal_addon_settings_post ( &$a, &$b ) +{ + if (! local_user()) + return; + + if (!x($_POST,'cal-submit')) + return; + + set_pconfig(local_user(),'cal','enable',intval($_POST['cal-enable'])); +} +function cal_addon_settings ( &$a, &$s ) +{ + if (! local_user()) + return; + + $enabled = get_pconfig(local_user(), 'cal', 'enable'); + $checked = (($enabled) ? ' checked="checked" ' : ''); + $url = $a->get_baseurl().'/cal/'.$a->user['nickname'].'/export/format'; + + $s .= ''; + $s .= '";
$o .= "\nDatabase Read:\n";
foreach ($a->callstack["database"] AS $func => $time) {
diff --git a/retriever/README b/retriever/README
new file mode 100644
index 00000000..b9728151
--- /dev/null
+++ b/retriever/README
@@ -0,0 +1,5 @@
+"retriever" is deactivated since it has side effects for all received posts.
+
+It was created in a time when the option 'Fetch further information for feeds' didn't exist.
+
+To activate it, please go to the list of your contacts, edit the contact and then select between the different options.
diff --git a/retriever/database.sql b/retriever/database.sql
new file mode 100644
index 00000000..23cac120
--- /dev/null
+++ b/retriever/database.sql
@@ -0,0 +1,36 @@
+CREATE TABLE IF NOT EXISTS `retriever_rule` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `uid` int(11) NOT NULL,
+ `contact-id` int(11) NOT NULL,
+ `data` mediumtext NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `uid` (`uid`),
+ KEY `contact-id` (`contact-id`)
+) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+CREATE TABLE IF NOT EXISTS `retriever_item` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `item-uri` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
+ `item-uid` int(10) unsigned NOT NULL DEFAULT '0',
+ `contact-id` int(10) unsigned NOT NULL DEFAULT '0',
+ `resource` int(11) NOT NULL,
+ `finished` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ KEY `resource` (`resource`),
+ KEY `all` (`item-uri`, `item-uid`, `contact-id`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+CREATE TABLE IF NOT EXISTS `retriever_resource` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `type` char(255) NOT NULL,
+ `binary` int(1) NOT NULL DEFAULT 0,
+ `url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
+ `created` timestamp NOT NULL DEFAULT now(),
+ `completed` timestamp NULL DEFAULT NULL,
+ `last-try` timestamp NULL DEFAULT NULL,
+ `num-tries` int(11) NOT NULL DEFAULT 0,
+ `data` mediumtext NOT NULL,
+ `http-code` smallint(1) unsigned NULL DEFAULT NULL,
+ `redirect-url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8 COLLATE=utf8_bin
diff --git a/retriever/lang/C/messages.po b/retriever/lang/C/messages.po
new file mode 100644
index 00000000..e9d20af2
--- /dev/null
+++ b/retriever/lang/C/messages.po
@@ -0,0 +1,102 @@
+# ADDON retriever
+# Copyright (C)
+# This file is distributed under the same license as the Friendica retriever addon package.
+#
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-23 14:45+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: retriever.php:445
+msgid "Retrieved"
+msgstr ""
+
+#: retriever.php:654
+msgid "Enabled"
+msgstr ""
+
+#: retriever.php:658
+msgid "URL Pattern"
+msgstr ""
+
+#: retriever.php:660
+msgid "Regular expression matching part of the URL to replace"
+msgstr ""
+
+#: retriever.php:663
+msgid "URL Replace"
+msgstr ""
+
+#: retriever.php:665
+msgid "Text to replace matching part of above regular expression"
+msgstr ""
+
+#: retriever.php:668
+msgid "Download Images"
+msgstr ""
+
+#: retriever.php:672
+msgid "Retrospectively Apply"
+msgstr ""
+
+#: retriever.php:674
+msgid "Reapply the rules to this number of posts"
+msgstr ""
+
+#: retriever.php:675
+msgid "Retrieve Feed Content"
+msgstr ""
+
+#: retriever.php:677 retriever.php:721
+msgid "Save Settings"
+msgstr ""
+
+#: retriever.php:679
+msgid "Tag"
+msgstr ""
+
+#: retriever.php:680
+msgid "Attribute"
+msgstr ""
+
+#: retriever.php:681
+msgid "Value"
+msgstr ""
+
+#: retriever.php:682
+msgid "Add"
+msgstr ""
+
+#: retriever.php:683
+msgid "Remove"
+msgstr ""
+
+#: retriever.php:684
+msgid "Include"
+msgstr ""
+
+#: retriever.php:686
+msgid "Exclude"
+msgstr ""
+
+#: retriever.php:697
+msgid "Retriever"
+msgstr ""
+
+#: retriever.php:722
+msgid "Retriever Settings"
+msgstr ""
+
+#: retriever.php:725
+msgid "All Photos"
+msgstr ""
diff --git a/retriever/retriever.php b/retriever/retriever.php
new file mode 100644
index 00000000..72e327b3
--- /dev/null
+++ b/retriever/retriever.php
@@ -0,0 +1,839 @@
+
+ * Status: Unsupported
+ */
+
+require_once('include/html2bbcode.php');
+require_once('include/Photo.php');
+
+function retriever_install() {
+ register_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
+ register_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
+ register_hook('post_remote', 'addon/retriever/retriever.php', 'retriever_post_remote_hook');
+ register_hook('contact_photo_menu', 'addon/retriever/retriever.php', 'retriever_contact_photo_menu');
+ register_hook('cron', 'addon/retriever/retriever.php', 'retriever_cron');
+
+ $r = q("SELECT `id` FROM `pconfig` WHERE `cat` LIKE 'retriever_%%'");
+ if (count($r) || (get_config('retriever', 'dbversion') == '0.1')) {
+ $retrievers = array();
+ $r = q("SELECT SUBSTRING(`cat`, 10) AS `contact`, `k`, `v` FROM `pconfig` WHERE `cat` LIKE 'retriever%%'");
+ foreach ($r as $rr) {
+ $retrievers[$rr['contact']][$rr['k']] = $rr['v'];
+ }
+ foreach ($retrievers as $k => $v) {
+ $rr = q("SELECT `uid` FROM `contact` WHERE `id` = %d", intval($k));
+ $uid = $rr[0]['uid'];
+ $v['images'] = 'on';
+ q("INSERT INTO `retriever_rule` (`uid`, `contact-id`, `data`) VALUES (%d, %d, '%s')",
+ intval($uid), intval($k), dbesc(json_encode($v)));
+ }
+ q("DELETE FROM `pconfig` WHERE `cat` LIKE 'retriever_%%'");
+ set_config('retriever', 'dbversion', '0.2');
+ }
+ if (get_config('retriever', 'dbversion') == '0.2') {
+ q("ALTER TABLE `retriever_resource` DROP COLUMN `retriever`");
+ set_config('retriever', 'dbversion', '0.3');
+ }
+ if (get_config('retriever', 'dbversion') == '0.3') {
+ q("ALTER TABLE `retriever_item` MODIFY COLUMN `item-uri` varchar(800) CHARACTER SET ascii NOT NULL");
+ q("ALTER TABLE `retriever_resource` MODIFY COLUMN `url` varchar(800) CHARACTER SET ascii NOT NULL");
+ set_config('retriever', 'dbversion', '0.4');
+ }
+ if (get_config('retriever', 'dbversion') == '0.4') {
+ q("ALTER TABLE `retriever_item` ADD COLUMN `finished` tinyint(1) unsigned NOT NULL DEFAULT '0'");
+ set_config('retriever', 'dbversion', '0.5');
+ }
+ if (get_config('retriever', 'dbversion') == '0.5') {
+ q('ALTER TABLE `retriever_resource` CHANGE `created` `created` timestamp NOT NULL DEFAULT now()');
+ q('ALTER TABLE `retriever_resource` CHANGE `completed` `completed` timestamp NULL DEFAULT NULL');
+ q('ALTER TABLE `retriever_resource` CHANGE `last-try` `last-try` timestamp NULL DEFAULT NULL');
+ q('ALTER TABLE `retriever_item` DROP KEY `all`');
+ q('ALTER TABLE `retriever_item` ADD KEY `all` (`item-uri`, `item-uid`, `contact-id`)');
+ set_config('retriever', 'dbversion', '0.6');
+ }
+ if (get_config('retriever', 'dbversion') == '0.6') {
+ q('ALTER TABLE `retriever_item` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
+ q('ALTER TABLE `retriever_item` CHANGE `item-uri` `item-uri` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL');
+ q('ALTER TABLE `retriever_resource` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
+ q('ALTER TABLE `retriever_resource` CHANGE `url` `url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL');
+ q('ALTER TABLE `retriever_rule` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
+ set_config('retriever', 'dbversion', '0.7');
+ }
+ if (get_config('retriever', 'dbversion') == '0.7') {
+ $r = q("SELECT `id`, `data` FROM `retriever_rule`");
+ foreach ($r as $rr) {
+ logger('retriever_install: retriever ' . $rr['id'] . ' old config ' . $rr['data'], LOGGER_DATA);
+ $data = json_decode($rr['data'], true);
+ if ($data['pattern']) {
+ $matches = array();
+ if (preg_match("/\/(.*)\//", $data['pattern'], $matches)) {
+ $data['pattern'] = $matches[1];
+ }
+ }
+ if ($data['match']) {
+ $include = array();
+ foreach (explode('|', $data['match']) as $component) {
+ $matches = array();
+ if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[@([A-Za-z][a-z0-9]*)='([^']*)'\]/", $component, $matches)) {
+ $include[] = array(
+ 'element' => $matches[1],
+ 'attribute' => $matches[2],
+ 'value' => $matches[3]);
+ }
+ if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[contains(concat(' ',normalize-space(@class),' '),' ([^ ']+) ')]/", $component, $matches)) {
+ $include[] = array(
+ 'element' => $matches[1],
+ 'attribute' => $matches[2],
+ 'value' => $matches[3]);
+ }
+ }
+ $data['include'] = $include;
+ unset($data['match']);
+ }
+ if ($data['remove']) {
+ $exclude = array();
+ foreach (explode('|', $data['remove']) as $component) {
+ $matches = array();
+ if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[@([A-Za-z][a-z0-9]*)='([^']*)'\]/", $component, $matches)) {
+ $exclude[] = array(
+ 'element' => $matches[1],
+ 'attribute' => $matches[2],
+ 'value' => $matches[3]);
+ }
+ if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[contains(concat(' ',normalize-space(@class),' '),' ([^ ']+) ')]/", $component, $matches)) {
+ $exclude[] = array(
+ 'element' => $matches[1],
+ 'attribute' => $matches[2],
+ 'value' => $matches[3]);
+ }
+ }
+ $data['exclude'] = $exclude;
+ unset($data['remove']);
+ }
+ $r = q('UPDATE `retriever_rule` SET `data` = "%s" WHERE `id` = %d', dbesc(json_encode($data)), $rr['id']);
+ logger('retriever_install: retriever ' . $rr['id'] . ' new config ' . json_encode($data), LOGGER_DATA);
+ }
+ set_config('retriever', 'dbversion', '0.8');
+ }
+ if (get_config('retriever', 'dbversion') == '0.8') {
+ q("ALTER TABLE `retriever_resource` ADD COLUMN `http-code` smallint(1) unsigned NULL DEFAULT NULL");
+ set_config('retriever', 'dbversion', '0.9');
+ }
+ if (get_config('retriever', 'dbversion') == '0.9') {
+ q("ALTER TABLE `retriever_item` DROP COLUMN `parent`");
+ q("ALTER TABLE `retriever_resource` ADD COLUMN `redirect-url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT NULL");
+ set_config('retriever', 'dbversion', '0.10');
+ }
+
+ if (get_config('retriever', 'dbversion') != '0.10') {
+ $schema = file_get_contents(dirname(__file__).'/database.sql');
+ $arr = explode(';', $schema);
+ foreach ($arr as $a) {
+ $r = q($a);
+ }
+ set_config('retriever', 'dbversion', '0.10');
+ }
+}
+
+function retriever_uninstall() {
+ unregister_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
+ unregister_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
+ unregister_hook('post_remote', 'addon/retriever/retriever.php', 'retriever_post_remote_hook');
+ unregister_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
+ unregister_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
+ unregister_hook('contact_photo_menu', 'addon/retriever/retriever.php', 'retriever_contact_photo_menu');
+ unregister_hook('cron', 'addon/retriever/retriever.php', 'retriever_cron');
+}
+
+function retriever_module() {}
+
+function retriever_cron($a, $b) {
+ // 100 is a nice sane number. Maybe this should be configurable.
+ retriever_retrieve_items(100);
+ retriever_tidy();
+}
+
+$retriever_item_count = 0;
+
+function retriever_retrieve_items($max_items) {
+ global $retriever_item_count;
+
+ $retriever_schedule = array(array(1,'minute'),
+ array(10,'minute'),
+ array(1,'hour'),
+ array(1,'day'),
+ array(2,'day'),
+ array(1,'week'),
+ array(1,'month'));
+
+ $schedule_clauses = array();
+ for ($i = 0; $i < count($retriever_schedule); $i++) {
+ $num = $retriever_schedule[$i][0];
+ $unit = $retriever_schedule[$i][1];
+ array_push($schedule_clauses,
+ '(`num-tries` = ' . $i . ' AND TIMESTAMPADD(' . dbesc($unit) .
+ ', ' . intval($num) . ', `last-try`) < now())');
+ }
+
+ $retrieve_items = $max_items - $retriever_item_count;
+ logger('retriever_retrieve_items: asked for maximum ' . $max_items . ', already retrieved ' . $retriever_item_count . ', retrieve ' . $retrieve_items, LOGGER_DEBUG);
+ do {
+ $r = q("SELECT * FROM `retriever_resource` WHERE `completed` IS NULL AND (`last-try` IS NULL OR %s) ORDER BY `last-try` ASC LIMIT %d",
+ dbesc(implode($schedule_clauses, ' OR ')),
+ intval($retrieve_items));
+ if (!is_array($r)) {
+ break;
+ }
+ if (count($r) == 0) {
+ break;
+ }
+ logger('retriever_retrieve_items: found ' . count($r) . ' waiting resources in database', LOGGER_DEBUG);
+ foreach ($r as $rr) {
+ retrieve_resource($rr);
+ $retriever_item_count++;
+ }
+ $retrieve_items = $max_items - $retriever_item_count;
+ }
+ while ($retrieve_items > 0);
+
+ /* Look for items that are waiting even though the resource has
+ * completed. This usually happens because we've been asked to
+ * retrospectively apply a config change. It could also happen
+ * due to a cron job dying or something. */
+ $r = q("SELECT retriever_resource.`id` as resource, retriever_item.`id` as item FROM retriever_resource, retriever_item, retriever_rule WHERE retriever_item.`finished` = 0 AND retriever_item.`resource` = retriever_resource.`id` AND retriever_resource.`completed` IS NOT NULL AND retriever_item.`contact-id` = retriever_rule.`contact-id` AND retriever_item.`item-uid` = retriever_rule.`uid` LIMIT %d",
+ intval($retrieve_items));
+ if (!$r) {
+ $r = array();
+ }
+ logger('retriever_retrieve_items: items waiting even though resource has completed: ' . count($r), LOGGER_DEBUG);
+ foreach ($r as $rr) {
+ $resource = q("SELECT * FROM retriever_resource WHERE `id` = %d", $rr['resource']);
+ $retriever_item = retriever_get_retriever_item($rr['item']);
+ if (!$retriever_item) {
+ logger('retriever_retrieve_items: no retriever item with id ' . $rr['item'], LOGGER_NORMAL);
+ continue;
+ }
+ $item = retriever_get_item($retriever_item);
+ if (!$item) {
+ logger('retriever_retrieve_items: no item ' . $retriever_item['item-uri'], LOGGER_NORMAL);
+ continue;
+ }
+ $retriever = get_retriever($item['contact-id'], $item['uid']);
+ if (!$retriever) {
+ logger('retriever_retrieve_items: no retriever for item ' .
+ $retriever_item['item-uri'] . ' ' . $retriever_item['uid'] . ' ' . $item['contact-id'],
+ LOGGER_NORMAL);
+ continue;
+ }
+ retriever_apply_completed_resource_to_item($retriever, $item, $resource[0]);
+ q("UPDATE `retriever_item` SET `finished` = 1 WHERE id = %d",
+ intval($retriever_item['id']));
+ retriever_check_item_completed($item);
+ }
+}
+
+function retriever_tidy() {
+ q("DELETE FROM retriever_resource WHERE completed IS NOT NULL AND completed < DATE_SUB(now(), INTERVAL 1 WEEK)");
+ q("DELETE FROM retriever_resource WHERE completed IS NULL AND created < DATE_SUB(now(), INTERVAL 3 MONTH)");
+
+ $r = q("SELECT retriever_item.id FROM retriever_item LEFT OUTER JOIN retriever_resource ON (retriever_item.resource = retriever_resource.id) WHERE retriever_resource.id is null");
+ logger('retriever_tidy: found ' . count($r) . ' retriever_items with no retriever_resource');
+ foreach ($r as $rr) {
+ q('DELETE FROM retriever_item WHERE id = %d', intval($rr['id']));
+ }
+}
+
+function retrieve_resource($resource) {
+ $a = get_app();
+
+ logger('retrieve_resource: ' . ($resource['num-tries'] + 1) .
+ ' attempt at resource ' . $resource['id'] . ' ' . $resource['url'], LOGGER_DEBUG);
+ $redirects;
+ $cookiejar = tempnam(get_temppath(), 'cookiejar-retriever-');
+ $fetch_result = z_fetch_url($resource['url'], $resource['binary'], $redirects, array('cookiejar' => $cookiejar));
+ unlink($cookiejar);
+ $resource['data'] = $fetch_result['body'];
+ $resource['http-code'] = $a->get_curl_code();
+ $resource['type'] = $a->get_curl_content_type();
+ $resource['redirect-url'] = $fetch_result['redirect_url'];
+ logger('retrieve_resource: got code ' . $resource['http-code'] .
+ ' retrieving resource ' . $resource['id'] .
+ ' final url ' . $resource['redirect-url'], LOGGER_DEBUG);
+ q("UPDATE `retriever_resource` SET `last-try` = now(), `num-tries` = `num-tries` + 1, `http-code` = %d, `redirect-url` = '%s' WHERE id = %d",
+ intval($resource['http-code']),
+ dbesc($resource['redirect-url']),
+ intval($resource['id']));
+ if ($resource['data']) {
+ q("UPDATE `retriever_resource` SET `completed` = now(), `data` = '%s', `type` = '%s' WHERE id = %d",
+ dbesc($resource['data']),
+ dbesc($resource['type']),
+ intval($resource['id']));
+ retriever_resource_completed($resource);
+ }
+}
+
+function get_retriever($contact_id, $uid, $create = false) {
+ $r = q("SELECT * FROM `retriever_rule` WHERE `contact-id` = %d AND `uid` = %d",
+ intval($contact_id), intval($uid));
+ if (count($r)) {
+ $r[0]['data'] = json_decode($r[0]['data'], true);
+ return $r[0];
+ }
+ if ($create) {
+ q("INSERT INTO `retriever_rule` (`uid`, `contact-id`) VALUES (%d, %d)",
+ intval($uid), intval($contact_id));
+ $r = q("SELECT * FROM `retriever_rule` WHERE `contact-id` = %d AND `uid` = %d",
+ intval($contact_id), intval($uid));
+ return $r[0];
+ }
+}
+
+function retriever_get_retriever_item($id) {
+ $retriever_items = q("SELECT * FROM `retriever_item` WHERE id = %d", intval($id));
+ if (count($retriever_items) != 1) {
+ logger('retriever_get_retriever_item: unable to find retriever_item ' . $id, LOGGER_NORMAL);
+ return;
+ }
+ return $retriever_items[0];
+}
+
+function retriever_get_item($retriever_item) {
+ $items = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `contact-id` = %d",
+ dbesc($retriever_item['item-uri']),
+ intval($retriever_item['item-uid']),
+ intval($retriever_item['contact-id']));
+ if (count($items) != 1) {
+ logger('retriever_get_item: unexpected number of results ' .
+ count($items) . " when searching for item $uri $uid $cid", LOGGER_NORMAL);
+ return;
+ }
+ return $items[0];
+}
+
+function retriever_item_completed($retriever_item_id, $resource) {
+ logger('retriever_item_completed: id ' . $retriever_item_id . ' url ' . $resource['url'], LOGGER_DEBUG);
+
+ $retriever_item = retriever_get_retriever_item($retriever_item_id);
+ if (!$retriever_item) {
+ return;
+ }
+ // Note: the retriever might be null. Doesn't matter.
+ $retriever = get_retriever($retriever_item['contact-id'], $retriever_item['item-uid']);
+ $item = retriever_get_item($retriever_item);
+ if (!$item) {
+ return;
+ }
+
+ retriever_apply_completed_resource_to_item($retriever, $item, $resource);
+
+ q("UPDATE `retriever_item` SET `finished` = 1 WHERE id = %d",
+ intval($retriever_item['id']));
+ retriever_check_item_completed($item);
+}
+
+function retriever_resource_completed($resource) {
+ logger('retriever_resource_completed: id ' . $resource['id'] . ' url ' . $resource['url'], LOGGER_DEBUG);
+ $r = q("SELECT `id` FROM `retriever_item` WHERE `resource` = %d", $resource['id']);
+ foreach ($r as $rr) {
+ retriever_item_completed($rr['id'], $resource);
+ }
+}
+
+function apply_retrospective($retriever, $num) {
+ $r = q("SELECT * FROM `item` WHERE `contact-id` = %d ORDER BY `received` DESC LIMIT %d",
+ intval($retriever['contact-id']), intval($num));
+ foreach ($r as $item) {
+ q('UPDATE `item` SET `visible` = 0 WHERE `id` = %d', $item['id']);
+ q('UPDATE `thread` SET `visible` = 0 WHERE `iid` = %d', $item['id']);
+ retriever_on_item_insert($retriever, $item);
+ }
+}
+
+function retriever_on_item_insert($retriever, &$item) {
+ if (!$retriever || !$retriever['id']) {
+ logger('retriever_on_item_insert: No retriever supplied', LOGGER_NORMAL);
+ return;
+ }
+ if (!$retriever["data"]['enable'] == "on") {
+ return;
+ }
+ if ($retriever["data"]['pattern']) {
+ $url = preg_replace('/' . $retriever["data"]['pattern'] . '/', $retriever["data"]['replace'], $item['plink']);
+ logger('retriever_on_item_insert: Changed ' . $item['plink'] . ' to ' . $url, LOGGER_DATA);
+ }
+ else {
+ $url = $item['plink'];
+ }
+
+ $resource = add_retriever_resource($url);
+ $retriever_item_id = add_retriever_item($item, $resource);
+}
+
+function add_retriever_resource($url, $binary = false) {
+ logger('add_retriever_resource: ' . $url, LOGGER_DEBUG);
+
+ $scheme = parse_url($url, PHP_URL_SCHEME);
+ if ($scheme == 'data') {
+ $fp = fopen($url, 'r');
+ $meta = stream_get_meta_data($fp);
+ $type = $meta['mediatype'];
+ $data = stream_get_contents($fp);
+ fclose($fp);
+
+ $url = 'md5://' . hash('md5', $url);
+ $r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
+ $resource = $r[0];
+ if (count($r)) {
+ logger('add_retriever_resource: Resource ' . $url . ' already requested', LOGGER_DEBUG);
+ return $resource;
+ }
+
+ logger('retrieve_resource: got data URL type ' . $resource['type'], LOGGER_DEBUG);
+ q("INSERT INTO `retriever_resource` (`type`, `binary`, `url`, `completed`, `data`) " .
+ "VALUES ('%s', %d, '%s', now(), '%s')",
+ dbesc($type),
+ intval($binary ? 1 : 0),
+ dbesc($url),
+ dbesc($data));
+ $r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
+ $resource = $r[0];
+ if (count($r)) {
+ retriever_resource_completed($resource);
+ }
+ return $resource;
+ }
+
+ if (strlen($url) > 800) {
+ logger('add_retriever_resource: URL is longer than 800 characters', LOGGER_NORMAL);
+ }
+
+ $r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
+ $resource = $r[0];
+ if (count($r)) {
+ logger('add_retriever_resource: Resource ' . $url . ' already requested', LOGGER_DEBUG);
+ return $resource;
+ }
+
+ q("INSERT INTO `retriever_resource` (`binary`, `url`) " .
+ "VALUES (%d, '%s')", intval($binary ? 1 : 0), dbesc($url));
+ $r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
+ return $r[0];
+}
+
+function add_retriever_item(&$item, $resource) {
+ logger('add_retriever_item: ' . $resource['url'] . ' for ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
+
+ q("INSERT INTO `retriever_item` (`item-uri`, `item-uid`, `contact-id`, `resource`) " .
+ "VALUES ('%s', %d, %d, %d)",
+ dbesc($item['uri']), intval($item['uid']), intval($item['contact-id']), intval($resource["id"]));
+ $r = q("SELECT id FROM `retriever_item` WHERE " .
+ "`item-uri` = '%s' AND `item-uid` = %d AND `contact-id` = %d AND `resource` = %d ORDER BY id DESC",
+ dbesc($item['uri']), intval($item['uid']), intval($item['contact-id']), intval($resource['id']));
+ if (!count($r)) {
+ logger("add_retriever_item: couldn't create retriever item for " .
+ $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'],
+ LOGGER_NORMAL);
+ return;
+ }
+ logger('add_retriever_item: created retriever_item ' . $r[0]['id'] . ' for item ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
+ return $r[0]['id'];
+}
+
+function retriever_get_encoding($resource) {
+ $matches = array();
+ if (preg_match('/charset=(.*)/', $resource['type'], $matches)) {
+ return trim(array_pop($matches));
+ }
+ return 'utf-8';
+}
+
+function retriever_apply_xslt_text($xslt_text, $doc) {
+ if (!$xslt_text) {
+ logger('retriever_apply_xslt_text: empty XSLT text', LOGGER_NORMAL);
+ return $doc;
+ }
+ $xslt_doc = new DOMDocument();
+ if (!$xslt_doc->loadXML($xslt_text)) {
+ logger('retriever_apply_xslt_text: could not load XML', LOGGER_NORMAL);
+ return $doc;
+ }
+ $xp = new XsltProcessor();
+ $xp->importStylesheet($xslt_doc);
+ $result = $xp->transformToDoc($doc);
+ return $result;
+}
+
+function retriever_apply_dom_filter($retriever, &$item, $resource) {
+ logger('retriever_apply_dom_filter: applying XSLT to ' . $item['id'] . ' ' . $item['uri'] . ' contact ' . $item['contact-id'], LOGGER_DEBUG);
+
+ if (!$retriever['data']['include'] && !$retriever['data']['customxslt']) {
+ return;
+ }
+ if (!$resource['data']) {
+ logger('retriever_apply_dom_filter: no text to work with', LOGGER_NORMAL);
+ return;
+ }
+
+ $encoding = retriever_get_encoding($resource);
+ $content = mb_convert_encoding($resource['data'], 'HTML-ENTITIES', $encoding);
+ $doc = new DOMDocument('1.0', 'UTF-8');
+ if (strpos($resource['type'], 'html') !== false) {
+ @$doc->loadHTML($content);
+ }
+ else {
+ $doc->loadXML($content);
+ }
+
+ $params = array('$spec' => $retriever['data']);
+ $extract_template = get_markup_template('extract.tpl', 'addon/retriever/');
+ $extract_xslt = replace_macros($extract_template, $params);
+ if ($retriever['data']['include']) {
+ $doc = retriever_apply_xslt_text($extract_xslt, $doc);
+ }
+ if ($retriever['data']['customxslt']) {
+ $doc = retriever_apply_xslt_text($retriever['data']['customxslt'], $doc);
+ }
+ if (!$doc) {
+ logger('retriever_apply_dom_filter: failed to apply extract XSLT template', LOGGER_NORMAL);
+ return;
+ }
+
+ $components = parse_url($resource['redirect-url']);
+ $rooturl = $components['scheme'] . "://" . $components['host'];
+ $dirurl = $rooturl . dirname($components['path']) . "/";
+ $params = array('$dirurl' => $dirurl, '$rooturl' => $rooturl);
+ $fix_urls_template = get_markup_template('fix-urls.tpl', 'addon/retriever/');
+ $fix_urls_xslt = replace_macros($fix_urls_template, $params);
+ $doc = retriever_apply_xslt_text($fix_urls_xslt, $doc);
+ if (!$doc) {
+ logger('retriever_apply_dom_filter: failed to apply fix urls XSLT template', LOGGER_NORMAL);
+ return;
+ }
+
+ $item['body'] = html2bbcode($doc->saveXML());
+ if (!strlen($item['body'])) {
+ logger('retriever_apply_dom_filter retriever ' . $retriever['id'] . ' item ' . $item['id'] . ': output was empty', LOGGER_NORMAL);
+ return;
+ }
+ $item['body'] .= "\n\n" . t('Retrieved') . ' ' . date("Y-m-d") . ': [url=';
+ $item['body'] .= $item['plink'];
+ $item['body'] .= ']' . $item['plink'] . '[/url]';
+ q("UPDATE `item` SET `body` = '%s' WHERE `id` = %d",
+ dbesc($item['body']), intval($item['id']));
+}
+
+function retrieve_images(&$item) {
+ $matches1 = array();
+ preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1);
+ $matches2 = array();
+ preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2);
+ $matches = array_merge($matches1[3], $matches2[1]);
+ logger('retrieve_images: found ' . count($matches) . ' images for item ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
+ foreach ($matches as $url) {
+ if (strpos($url, get_app()->get_baseurl()) === FALSE) {
+ $resource = add_retriever_resource($url, true);
+ if (!$resource['completed']) {
+ add_retriever_item($item, $resource);
+ }
+ else {
+ retriever_transform_images($item, $resource);
+ }
+ }
+ }
+}
+
+function retriever_check_item_completed(&$item)
+{
+ $r = q('SELECT count(*) FROM retriever_item WHERE `item-uri` = "%s" ' .
+ 'AND `item-uid` = %d AND `contact-id` = %d AND `finished` = 0',
+ dbesc($item['uri']), intval($item['uid']),
+ intval($item['contact-id']));
+ $waiting = $r[0]['count(*)'];
+ logger('retriever_check_item_completed: item ' . $item['uri'] . ' ' . $item['uid']
+ . ' '. $item['contact-id'] . ' waiting for ' . $waiting . ' resources', LOGGER_DEBUG);
+ $old_visible = $item['visible'];
+ $item['visible'] = $waiting ? 0 : 1;
+ if (($item['id'] > 0) && ($old_visible != $item['visible'])) {
+ logger('retriever_check_item_completed: changing visible flag to ' . $item['visible'] . ' and invoking notifier ("edit_post", ' . $item['id'] . ')', LOGGER_DEBUG);
+ q("UPDATE `item` SET `visible` = %d WHERE `id` = %d",
+ intval($item['visible']),
+ intval($item['id']));
+ q("UPDATE `thread` SET `visible` = %d WHERE `iid` = %d",
+ intval($item['visible']),
+ intval($item['id']));
+ }
+}
+
+function retriever_apply_completed_resource_to_item($retriever, &$item, $resource) {
+ logger('retriever_apply_completed_resource_to_item: retriever ' .
+ ($retriever ? $retriever['id'] : 'none') .
+ ' resource ' . $resource['url'] . ' plink ' . $item['plink'], LOGGER_DEBUG);
+ if (strpos($resource['type'], 'image') !== false) {
+ retriever_transform_images($item, $resource);
+ }
+ if (!$retriever) {
+ return;
+ }
+ if ((strpos($resource['type'], 'html') !== false) ||
+ (strpos($resource['type'], 'xml') !== false)) {
+ retriever_apply_dom_filter($retriever, $item, $resource);
+ if ($retriever["data"]['images'] ) {
+ retrieve_images($item);
+ }
+ }
+}
+
+function retriever_store_photo($item, &$resource) {
+ $hash = photo_new_resource();
+
+ if (class_exists('Imagick')) {
+ try {
+ $image = new Imagick();
+ $image->readImageBlob($resource['data']);
+ $resource['width'] = $image->getImageWidth();
+ $resource['height'] = $image->getImageHeight();
+ }
+ catch (Exception $e) {
+ logger("ImageMagick couldn't process image " . $resource['id'] . " " . $resource['url'] . ' length ' . strlen($resource['data']) . ': ' . $e->getMessage(), LOGGER_DEBUG);
+ return false;
+ }
+ }
+ if (!array_key_exists('width', $resource)) {
+ $image = @imagecreatefromstring($resource['data']);
+ if ($image === false) {
+ logger("Couldn't process image " . $resource['id'] . " " . $resource['url'], LOGGER_DEBUG);
+ return false;
+ }
+ $resource['width'] = imagesx($image);
+ $resource['height'] = imagesy($image);
+ imagedestroy($image);
+ }
+
+ $url_components = parse_url($resource['url']);
+ $filename = basename($url_components['path']);
+ if (!strlen($filename)) {
+ $filename = 'image';
+ }
+ $r = q("INSERT INTO `photo`
+ ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `type`, `album`, `height`, `width`, `datasize`, `data` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' )",
+ intval($item['item-uid']),
+ intval($item['contact-id']),
+ dbesc(get_guid()),
+ dbesc($hash),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($filename),
+ dbesc($resource['type']),
+ dbesc('Retrieved Images'),
+ intval($resource['height']),
+ intval($resource['width']),
+ intval(strlen($resource['data'])),
+ dbesc($resource['data'])
+ );
+
+ return $hash;
+}
+
+function retriever_transform_images(&$item, $resource) {
+ if (!$resource["data"]) {
+ logger('retriever_transform_images: no data available for '
+ . $resource['id'] . ' ' . $resource['url'], LOGGER_NORMAL);
+ return;
+ }
+
+ $hash = retriever_store_photo($item, $resource);
+ if ($hash === false) {
+ logger('retriever_transform_images: unable to store photo '
+ . $resource['id'] . ' ' . $resource['url'], LOGGER_NORMAL);
+ return;
+ }
+
+ $new_url = get_app()->get_baseurl() . '/photo/' . $hash;
+ logger('retriever_transform_images: replacing ' . $resource['url'] . ' with ' .
+ $new_url . ' in item ' . $item['plink'], LOGGER_DEBUG);
+ $transformed = str_replace($resource["url"], $new_url, $item['body']);
+ if ($transformed === $item['body']) {
+ return;
+ }
+
+ $item['body'] = $transformed;
+ q("UPDATE `item` SET `body` = '%s' WHERE `plink` = '%s' AND `uid` = %d AND `contact-id` = %d",
+ dbesc($item['body']),
+ dbesc($item['plink']),
+ intval($item['uid']),
+ intval($item['contact-id']));
+}
+
+function retriever_content($a) {
+ if (!local_user()) {
+ $a->page['content'] .= "Please log in
";
+ return;
+ }
+ if ($a->argv[1] === 'help') {
+ $feeds = q("SELECT `id`, `name`, `thumb` FROM contact WHERE `uid` = %d AND `network` = 'feed'",
+ local_user());
+ foreach ($feeds as $k=>$v) {
+ $feeds[$k]['url'] = $a->get_baseurl() . '/retriever/' . $v['id'];
+ }
+ $template = get_markup_template('/help.tpl', 'addon/retriever/');
+ $a->page['content'] .= replace_macros($template, array(
+ '$config' => $a->get_baseurl() . '/settings/addon',
+ '$feeds' => $feeds));
+ return;
+ }
+ if ($a->argv[1]) {
+ $retriever = get_retriever($a->argv[1], local_user(), false);
+
+ if (x($_POST["id"])) {
+ $retriever = get_retriever($a->argv[1], local_user(), true);
+ $retriever["data"] = array();
+ foreach (array('pattern', 'replace', 'enable', 'images', 'customxslt') as $setting) {
+ if (x($_POST['retriever_' . $setting])) {
+ $retriever["data"][$setting] = $_POST['retriever_' . $setting];
+ }
+ }
+ foreach ($_POST as $k=>$v) {
+ if (preg_match("/retriever-(include|exclude)-(\d+)-(element|attribute|value)/", $k, $matches)) {
+ $retriever['data'][$matches[1]][intval($matches[2])][$matches[3]] = $v;
+ }
+ }
+ // You've gotta have an element, even if it's just "*"
+ foreach ($retriever['data']['include'] as $k=>$clause) {
+ if (!$clause['element']) {
+ unset($retriever['data']['include'][$k]);
+ }
+ }
+ foreach ($retriever['data']['exclude'] as $k=>$clause) {
+ if (!$clause['element']) {
+ unset($retriever['data']['exclude'][$k]);
+ }
+ }
+ q("UPDATE `retriever_rule` SET `data`='%s' WHERE `id` = %d",
+ dbesc(json_encode($retriever["data"])), intval($retriever["id"]));
+ $a->page['content'] .= "Settings Updated";
+ if (x($_POST["retriever_retrospective"])) {
+ apply_retrospective($retriever, $_POST["retriever_retrospective"]);
+ $a->page['content'] .= " and retrospectively applied to " . $_POST["apply"] . " posts";
+ }
+ $a->page['content'] .= ".
";
+ }
+
+ $template = get_markup_template('/rule-config.tpl', 'addon/retriever/');
+ $a->page['content'] .= replace_macros($template, array(
+ '$enable' => array(
+ 'retriever_enable',
+ t('Enabled'),
+ $retriever['data']['enable']),
+ '$pattern' => array(
+ 'retriever_pattern',
+ t('URL Pattern'),
+ $retriever["data"]['pattern'],
+ t('Regular expression matching part of the URL to replace')),
+ '$replace' => array(
+ 'retriever_replace',
+ t('URL Replace'),
+ $retriever["data"]['replace'],
+ t('Text to replace matching part of above regular expression')),
+ '$images' => array(
+ 'retriever_images',
+ t('Download Images'),
+ $retriever['data']['images']),
+ '$retrospective' => array(
+ 'retriever_retrospective',
+ t('Retrospectively Apply'),
+ '0',
+ t('Reapply the rules to this number of posts')),
+ '$customxslt' => array(
+ 'retriever_customxslt',
+ t('Custom XSLT'),
+ $retriever['data']['customxslt'],
+ t("When standard rules aren't enough, apply custom XSLT to the article")),
+ '$title' => t('Retrieve Feed Content'),
+ '$help' => $a->get_baseurl() . '/retriever/help',
+ '$help_t' => t('Get Help'),
+ '$submit_t' => t('Submit'),
+ '$submit' => t('Save Settings'),
+ '$id' => ($retriever["id"] ? $retriever["id"] : "create"),
+ '$tag_t' => t('Tag'),
+ '$attribute_t' => t('Attribute'),
+ '$value_t' => t('Value'),
+ '$add_t' => t('Add'),
+ '$remove_t' => t('Remove'),
+ '$include_t' => t('Include'),
+ '$include' => $retriever['data']['include'],
+ '$exclude_t' => t('Exclude'),
+ '$exclude' => $retriever["data"]['exclude']));
+ return;
+ }
+}
+
+function retriever_contact_photo_menu($a, &$args) {
+ if (!$args) {
+ return;
+ }
+ if ($args["contact"]["network"] == "feed") {
+ $args["menu"][ 'retriever' ] = array(t('Retriever'), $a->get_baseurl() . '/retriever/' . $args["contact"]['id']);
+ }
+}
+
+function retriever_post_remote_hook(&$a, &$item) {
+ logger('retriever_post_remote_hook: ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
+
+ $retriever = get_retriever($item['contact-id'], $item["uid"], false);
+ if ($retriever) {
+ retriever_on_item_insert($retriever, $item);
+ }
+ else {
+ if (get_pconfig($item["uid"], 'retriever', 'oembed')) {
+ // Convert to HTML and back to take advantage of bbcode's resolution of oembeds.
+ $body = html2bbcode(bbcode($item['body']));
+ if ($body) {
+ $item['body'] = $body;
+ }
+ }
+ if (get_pconfig($item["uid"], 'retriever', 'all_photos')) {
+ retrieve_images($item, null);
+ }
+ }
+ retriever_check_item_completed($item);
+}
+
+function retriever_plugin_settings(&$a,&$s) {
+ $all_photos = get_pconfig(local_user(), 'retriever', 'all_photos');
+ $oembed = get_pconfig(local_user(), 'retriever', 'oembed');
+ $template = get_markup_template('/settings.tpl', 'addon/retriever/');
+ $s .= replace_macros($template, array(
+ '$allphotos' => array(
+ 'retriever_all_photos',
+ t('All Photos'),
+ $all_photos,
+ t('Check this to retrieve photos for all posts')),
+ '$oembed' => array(
+ 'retriever_oembed',
+ t('Resolve OEmbed'),
+ $oembed,
+ t('Check this to attempt to retrieve embedded content for all posts - useful e.g. for Facebook posts')),
+ '$submit' => t('Save Settings'),
+ '$title' => t('Retriever Settings'),
+ '$help' => $a->get_baseurl() . '/retriever/help'));
+}
+
+function retriever_plugin_settings_post($a,$post) {
+ if ($_POST['retriever_all_photos']) {
+ set_pconfig(local_user(), 'retriever', 'all_photos', $_POST['retriever_all_photos']);
+ }
+ else {
+ del_pconfig(local_user(), 'retriever', 'all_photos');
+ }
+ if ($_POST['retriever_oembed']) {
+ set_pconfig(local_user(), 'retriever', 'oembed', $_POST['retriever_oembed']);
+ }
+ else {
+ del_pconfig(local_user(), 'retriever', 'oembed');
+ }
+}
diff --git a/retriever/templates/extract.tpl b/retriever/templates/extract.tpl
new file mode 100644
index 00000000..fd38bde6
--- /dev/null
+++ b/retriever/templates/extract.tpl
@@ -0,0 +1,31 @@
+
+
+
+
+
+{{function clause_xpath}}
+{{if !$clause.attribute}}
+{{$clause.element}}{{elseif $clause.attribute == 'class'}}
+{{$clause.element}}[contains(concat(' ', normalize-space(@class), ' '), '{{$clause.value}}')]{{else}}
+{{$clause.element}}[@{{$clause.attribute}}='{{$clause.value}}']{{/if}}
+{{/function}}
+
+{{foreach $spec.include as $clause}}
+
+
+
+
+
+{{/foreach}}
+
+{{foreach $spec.exclude as $clause}}
+
+{{/foreach}}
+
+
+
+
+
+
+
+
diff --git a/retriever/templates/fix-urls.tpl b/retriever/templates/fix-urls.tpl
new file mode 100644
index 00000000..5bb665ab
--- /dev/null
+++ b/retriever/templates/fix-urls.tpl
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/retriever/templates/help.tpl b/retriever/templates/help.tpl
new file mode 100644
index 00000000..10b421d0
--- /dev/null
+++ b/retriever/templates/help.tpl
@@ -0,0 +1,148 @@
+Retriever Plugin Help
+
+This plugin replaces the short excerpts you normally get in RSS feeds
+with the full content of the article from the source website. You
+specify which part of the page you're interested in with a set of
+rules. When each item arrives, the plugin downloads the full page
+from the website, extracts content using the rules, and replaces the
+original article.
+
+
+There's a few reasons you may want to do this. The source website
+might be slow or overloaded. The source website might be
+untrustworthy, in which case using Friendica to scrub the HTML is a
+good idea. You might be on a LAN that blacklists certain websites.
+It also works neatly with the mailstream plugin, allowing you to read
+a news stream comfortably without needing continuous Internet
+connectivity.
+
+
+However, setting up retriever can be quite tricky since it depends on
+the internal design of the website. That was designed to make life
+easy for the website's developers, not for you. You'll need to have
+some familiarity with HTML, and be willing to adapt when the website
+suddenly changes everything without notice.
+
+Configuring Retriever for a feed
+
+To set up retriever for an RSS feed, go to the "Contacts" page and
+find your feed. Then click on the drop-down menu on the contact.
+Select "Retriever" to get to the retriever configuration.
+
+
+The "Include" configuration section specifies parts of the page to
+include in the article. Each row has three components:
+
+
+- An HTML tag (e.g. "div", "span", "p")
+- An attribute (usually "class" or "id")
+- A value for the attribute
+
+
+A simple case is when the article is wrapped in a "div" element:
+
+
+ ...
+ <div class="ArticleWrapper">
+ <h2>Man Bites Dog</h2>
+ <img src="mbd.jpg">
+ <p>
+ Residents of the sleepy community of Nowheresville were
+ shocked yesterday by the sight of creepy local weirdo Jim
+ McOddman assaulting innocent local dog Snufflekins with his
+ false teeth.
+ </p>
+ ...
+ </div>
+ ...
+
+
+You then specify the tag "div", attribute "class", and value
+"ArticleWrapper". Everything else in the page, such as navigation
+panels and menus and footers and so on, will be discarded. If there
+is more than one section of the page you want to include, specify each
+one on a separate row. If the matching section contains some sections
+you want to remove, specify those in the "Exclude" section in the same
+way.
+
+
+Once you've got a configuration that you think will work, you can try
+it out on some existing articles. Type a number into the
+"Retrospectively Apply" box and click "Submit". After a while
+(exactly how long depends on your system's cron configuration) the new
+articles should be available.
+
+Techniques
+
+You can leave the attribute and value blank to include all the
+corresponding elements with the specified tag name. You can also use
+a tag name of just an asterisk ("*"), which will match any element type with the
+specified attribute regardless of the tag.
+
+
+Note that the "class" attribute is a special case. Many web page
+templates will put multiple different classes in the same element,
+separated by spaces. If you specify an attribute of "class" it will
+match an element if any of its classes matches the specified value.
+For example:
+
+
+ <div class="article breaking-news">
+
+
+In this case you can specify a value of "article", or "breaking-news".
+You can also specify "article breaking-news", but that won't match if
+the website suddenly changes to "breaking-news article", so that's not
+recommended.
+
+
+One useful trick you can try is using the website's "print" pages.
+Many news sites have print versions of all their articles. These are
+usually drastically simplified compared to the live website page.
+Sometimes this is a good way to get the whole article when it's
+normally split across multiple pages.
+
+
+Hopefully the URL for the print page is a predictable variant of the
+normal article URL. For example, an article URL like:
+
+
+ http://www.newssite.com/article-8636.html
+
+
+...might have a print version at:
+
+
+ http://www.newssite.com/print/article-8636.html
+
+
+To change the URL used to retrieve the page, use the "URL Pattern" and
+"URL Replace" fields. The pattern is a regular expression matching
+part of the URL to replace. In this case, you might use a pattern of
+"/article" and a replace string of "/print/article". A common pattern
+is simply a dollar sign ("$"), used to add the replace string to the end of the URL.
+
+Background Processing
+
+Note that retrieving and processing the articles can take some time,
+so it's done in the background. Incoming articles will be marked as
+invisible while they're in the process of being downloaded. If a URL
+fails, the plugin will keep trying at progressively longer intervals
+for up to a month, in case the website is temporarily overloaded or
+the network is down.
+
+Retrieving Images
+
+Retriever can also optionally download images and store them in the
+local Friendica instance. Just check the "Download Images" box. You
+can also download images in every item from your network, whether it's
+an RSS feed or not. Go to the "Settings" page and
+click "Plugin settings". Then check the "All
+Photos" box in the "Retriever Settings" section and click "Submit".
+
+Configure Feeds:
+
+{{foreach $feeds as $feed}}
+{{include file='contact_template.tpl' contact=$feed}}
+{{/foreach}}
+
diff --git a/retriever/templates/rule-config.tpl b/retriever/templates/rule-config.tpl
new file mode 100644
index 00000000..228d0326
--- /dev/null
+++ b/retriever/templates/rule-config.tpl
@@ -0,0 +1,112 @@
+
+
+ {{$title}}
+
+
+
diff --git a/retriever/templates/settings.tpl b/retriever/templates/settings.tpl
new file mode 100644
index 00000000..8bfe8db0
--- /dev/null
+++ b/retriever/templates/settings.tpl
@@ -0,0 +1,9 @@
+
+ {{$title}}
+
+ Get Help
+
+{{include file="field_checkbox.tpl" field=$allphotos}}
+{{include file="field_checkbox.tpl" field=$oembed}}
+
+
diff --git a/securemail/securemail.php b/securemail/securemail.php
index 68fc24ff..b20eab9c 100644
--- a/securemail/securemail.php
+++ b/securemail/securemail.php
@@ -7,8 +7,8 @@
*/
use Friendica\App;
-use Friendica\Core\PConfig;
-use Friendica\Util\Emailer;
+
+require_once 'include/Emailer.php';
/* because the fraking openpgp-php is in composer, require libs in composer
* and then don't use autoloader to load classes... */
@@ -55,18 +55,18 @@ function securemail_settings(App &$a, &$s){
return;
}
- $enable = intval(PConfig::get(local_user(), 'securemail', 'enable'));
- $publickey = PConfig::get(local_user(), 'securemail', 'pkey');
+ $enable = intval(get_pconfig(local_user(), 'securemail', 'enable'));
+ $publickey = get_pconfig(local_user(), 'securemail', 'pkey');
$t = get_markup_template('admin.tpl', 'addon/securemail/');
- $s .= replace_macros($t, [
+ $s .= replace_macros($t, array(
'$title' => t('"Secure Mail" Settings'),
'$submit' => t('Save Settings'),
'$test' => t('Save and send test'), //NOTE: update also in 'post'
- '$enable' => ['securemail-enable', t('Enable Secure Mail'), $enable, ''],
- '$publickey' => ['securemail-pkey', t('Public key'), $publickey, t('Your public PGP key, ascii armored format'), 'rows="10"']
- ]);
+ '$enable' => array('securemail-enable', t('Enable Secure Mail'), $enable, ''),
+ '$publickey' => array('securemail-pkey', t('Public key'), $publickey, t('Your public PGP key, ascii armored format'), 'rows="10"')
+ ));
}
/**
@@ -86,9 +86,9 @@ function securemail_settings_post(App &$a, array &$b){
}
if ($_POST['securemail-submit']) {
- PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
+ set_pconfig(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
$enable = ((x($_POST, 'securemail-enable')) ? 1 : 0);
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
+ set_pconfig(local_user(), 'securemail', 'enable', $enable);
info(t('Secure Mail Settings saved.') . EOL);
if ($_POST['securemail-submit'] == t('Save and send test')) {
@@ -107,7 +107,7 @@ function securemail_settings_post(App &$a, array &$b){
$subject = 'Friendica - Secure Mail - Test';
$message = 'This is a test message from your Friendica Secure Mail addon.';
- $params = [
+ $params = array(
'uid' => local_user(),
'fromName' => $sitename,
'fromEmail' => $sender_email,
@@ -115,15 +115,15 @@ function securemail_settings_post(App &$a, array &$b){
'messageSubject' => $subject,
'htmlVersion' => "{$message}
",
'textVersion' => $message,
- ];
+ );
// enable addon for test
- PConfig::set(local_user(), 'securemail', 'enable', 1);
+ set_pconfig(local_user(), 'securemail', 'enable', 1);
$res = Emailer::send($params);
// revert to saved value
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
+ set_pconfig(local_user(), 'securemail', 'enable', $enable);
if ($res) {
info(t('Test email sent') . EOL);
@@ -151,12 +151,12 @@ function securemail_emailer_send_prepare(App &$a, array &$b) {
$uid = $b['uid'];
- $enable_checked = PConfig::get($uid, 'securemail', 'enable');
+ $enable_checked = get_pconfig($uid, 'securemail', 'enable');
if (!$enable_checked) {
return;
}
- $public_key_ascii = PConfig::get($uid, 'securemail', 'pkey');
+ $public_key_ascii = get_pconfig($uid, 'securemail', 'pkey');
preg_match('/-----BEGIN ([A-Za-z ]+)-----/', $public_key_ascii, $matches);
$marker = (empty($matches[1])) ? 'MESSAGE' : $matches[1];
@@ -164,11 +164,11 @@ function securemail_emailer_send_prepare(App &$a, array &$b) {
$key = OpenPGP_Message::parse($public_key);
- $data = new OpenPGP_LiteralDataPacket($b['textVersion'], [
+ $data = new OpenPGP_LiteralDataPacket($b['textVersion'], array(
'format' => 'u',
'filename' => 'encrypted.gpg'
- ]);
- $encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message([$data]));
+ ));
+ $encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message(array($data)));
$armored_encrypted = wordwrap(
OpenPGP::enarmor($encrypted->to_bytes(), 'PGP MESSAGE'),
64,
diff --git a/showmore/showmore.php b/showmore/showmore.php
index 9bddab63..a9d8334f 100644
--- a/showmore/showmore.php
+++ b/showmore/showmore.php
@@ -8,8 +8,6 @@
*
*/
-use Friendica\Core\PConfig;
-
function showmore_install() {
register_hook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body');
register_hook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings');
@@ -31,8 +29,8 @@ function showmore_addon_settings(&$a,&$s) {
$a->page['htmlhead'] .= ''."\r\n";
- $enable_checked = (intval(PConfig::get(local_user(),'showmore','disable')) ? '' : ' checked="checked"');
- $chars = PConfig::get(local_user(),'showmore','chars');
+ $enable_checked = (intval(get_pconfig(local_user(),'showmore','disable')) ? '' : ' checked="checked"');
+ $chars = get_pconfig(local_user(),'showmore','chars');
if(!$chars)
$chars = '1100';
@@ -66,10 +64,10 @@ function showmore_addon_settings_post(&$a,&$b) {
return;
if($_POST['showmore-submit']) {
- PConfig::set(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
+ set_pconfig(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
$enable = ((x($_POST,'showmore-enable')) ? intval($_POST['showmore-enable']) : 0);
$disable = 1-$enable;
- PConfig::set(local_user(),'showmore','disable', $disable);
+ set_pconfig(local_user(),'showmore','disable', $disable);
info( t('Show More Settings saved.') . EOL);
}
}
@@ -109,10 +107,10 @@ function get_body_length($body) {
function showmore_prepare_body(&$a,&$b) {
$words = null;
- if(PConfig::get(local_user(),'showmore','disable'))
+ if(get_pconfig(local_user(),'showmore','disable'))
return;
- $chars = (int)PConfig::get(local_user(),'showmore','chars');
+ $chars = (int)get_pconfig(local_user(),'showmore','chars');
if(!$chars)
$chars = 1100;
@@ -156,7 +154,7 @@ function showmore_cutitem($text, $limit) {
@$doc->loadHTML($doctype."".$text."");
$text = $doc->saveHTML();
- $text = str_replace(["", "", $doctype], ["", "", ""], $text);
+ $text = str_replace(array("", "", $doctype), array("", "", ""), $text);
return($text);
}
diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php
index d922a6b1..d8c15330 100644
--- a/smileybutton/smileybutton.php
+++ b/smileybutton/smileybutton.php
@@ -8,16 +8,16 @@
function smileybutton_install() {
- //Register hooks
+ //Register hooks
register_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button');
-
+
logger("installed smileybutton");
}
function smileybutton_uninstall() {
//Delet registered hooks
- unregister_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button');
+ unregister_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button');
logger("removed smileybutton");
}
@@ -41,34 +41,34 @@ function show_button($a, &$b) {
*
*/
- $texts = [
- '<3',
- '</3',
- ':-)',
- ';-)',
- ':-(',
- ':-P',
- ':-X',
- ':-D',
- ':-O',
- '\\\\o/',
- 'O_o',
- ":\'(",
- ":-!",
- ":-/",
- ":-[",
+ $texts = array(
+ '<3',
+ '</3',
+ ':-)',
+ ';-)',
+ ':-(',
+ ':-P',
+ ':-X',
+ ':-D',
+ ':-O',
+ '\\\\o/',
+ 'O_o',
+ ":\'(",
+ ":-!",
+ ":-/",
+ ":-[",
"8-)",
- ':beer',
- ':coffee',
+ ':beer',
+ ':coffee',
':facepalm',
':like',
':dislike',
'~friendica',
'red#'
- ];
+ );
- $icons = [
+ $icons = array(
'
',
'
',
'
',
@@ -77,7 +77,7 @@ function show_button($a, &$b) {
'
',
'
',
'
',
- '
',
+ '
',
'
',
'
',
'
',
@@ -92,10 +92,10 @@ function show_button($a, &$b) {
'
',
'
',
'
'
- ];
-
+ );
+
// Call hooks to get aditional smileies from other addons
- $params = ['texts' => $texts, 'icons' => $icons, 'string' => ""]; //changed
+ $params = array('texts' => $texts, 'icons' => $icons, 'string' => ""); //changed
call_hooks('smilie', $params);
//Generate html for smiley list
@@ -113,16 +113,16 @@ function show_button($a, &$b) {
//Add css to header
$css_file = 'addon/smileybutton/view/'.current_theme().'.css';
- if (! file_exists($css_file))
+ if (! file_exists($css_file))
$css_file = 'addon/smileybutton/view/default.css';
$css_url = $a->get_baseurl().'/'.$css_file;
$a->page['htmlhead'] .= ''."\r\n";
-
+
//Get the correct image for the theme
$image = 'addon/smileybutton/view/'.current_theme().'.png';
- if (! file_exists($image))
+ if (! file_exists($image))
$image = 'addon/smileybutton/view/default.png';
$image_url = $a->get_baseurl().'/'.$image;
diff --git a/snautofollow/lang/C/messages.po b/snautofollow/lang/C/messages.po
new file mode 100644
index 00000000..1cfdbc5a
--- /dev/null
+++ b/snautofollow/lang/C/messages.po
@@ -0,0 +1,34 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-27 05:01-0500\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr ""
+
+#: snautofollow.php:56
+msgid "StatusNet AutoFollow Settings"
+msgstr ""
+
+#: snautofollow.php:58
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr ""
+
+#: snautofollow.php:64
+msgid "Submit"
+msgstr ""
diff --git a/snautofollow/lang/ca/strings.php b/snautofollow/lang/ca/strings.php
new file mode 100644
index 00000000..824361aa
--- /dev/null
+++ b/snautofollow/lang/ca/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "Ajustos de AutoSeguiment a StatusNet actualitzats.";
+$a->strings["StatusNet AutoFollow Settings"] = "Ajustos de AutoSeguiment a StatusNet";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Segueix Automaticament qualsevol seguidor/mencionador de StatusNet";
+$a->strings["Submit"] = "Enviar";
diff --git a/snautofollow/lang/cs/messages.po b/snautofollow/lang/cs/messages.po
new file mode 100644
index 00000000..933478c2
--- /dev/null
+++ b/snautofollow/lang/cs/messages.po
@@ -0,0 +1,36 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+# Translators:
+# Michal Šupler , 2014
+msgid ""
+msgstr ""
+"Project-Id-Version: friendica\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-23 14:45+0200\n"
+"PO-Revision-Date: 2014-07-28 18:12+0000\n"
+"Last-Translator: Michal Šupler \n"
+"Language-Team: Czech (http://www.transifex.com/projects/p/friendica/language/cs/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: cs\n"
+"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr "Nastavení automatického následování na StatusNet aktualizováno."
+
+#: snautofollow.php:56 snautofollow.php:60
+msgid "StatusNet AutoFollow"
+msgstr "Nastavení StatusNet automatického následování (AutoFollow)"
+
+#: snautofollow.php:64
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr "Automaticky následovat jakékoliv StatusNet následníky/přispivatele"
+
+#: snautofollow.php:70
+msgid "Save Settings"
+msgstr "Uložit Nastavení"
diff --git a/snautofollow/lang/cs/strings.php b/snautofollow/lang/cs/strings.php
new file mode 100644
index 00000000..144b8d8e
--- /dev/null
+++ b/snautofollow/lang/cs/strings.php
@@ -0,0 +1,11 @@
+=2 && $n<=4) ? 1 : 2;;
+}}
+;
+$a->strings["StatusNet AutoFollow settings updated."] = "Nastavení automatického následování na StatusNet aktualizováno.";
+$a->strings["StatusNet AutoFollow"] = "Nastavení StatusNet automatického následování (AutoFollow)";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Automaticky následovat jakékoliv StatusNet následníky/přispivatele";
+$a->strings["Save Settings"] = "Uložit Nastavení";
diff --git a/snautofollow/lang/de/messages.po b/snautofollow/lang/de/messages.po
new file mode 100644
index 00000000..fb19d4ff
--- /dev/null
+++ b/snautofollow/lang/de/messages.po
@@ -0,0 +1,36 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+# Translators:
+# bavatar , 2014
+msgid ""
+msgstr ""
+"Project-Id-Version: friendica\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-23 14:45+0200\n"
+"PO-Revision-Date: 2014-10-02 14:39+0000\n"
+"Last-Translator: bavatar \n"
+"Language-Team: German (http://www.transifex.com/projects/p/friendica/language/de/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: de\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr "StatusNet AutoFollow Einstellungen aktualisiert."
+
+#: snautofollow.php:56 snautofollow.php:60
+msgid "StatusNet AutoFollow"
+msgstr "StatusNet AutoFollow"
+
+#: snautofollow.php:64
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr "Automatisch allen StatusNet Followern/Erwähnungen folgen"
+
+#: snautofollow.php:70
+msgid "Save Settings"
+msgstr "Einstellungen speichern"
diff --git a/snautofollow/lang/de/strings.php b/snautofollow/lang/de/strings.php
new file mode 100644
index 00000000..83e99b85
--- /dev/null
+++ b/snautofollow/lang/de/strings.php
@@ -0,0 +1,11 @@
+strings["StatusNet AutoFollow settings updated."] = "StatusNet AutoFollow Einstellungen aktualisiert.";
+$a->strings["StatusNet AutoFollow"] = "StatusNet AutoFollow";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Automatisch allen StatusNet Followern/Erwähnungen folgen";
+$a->strings["Save Settings"] = "Einstellungen speichern";
diff --git a/snautofollow/lang/eo/strings.php b/snautofollow/lang/eo/strings.php
new file mode 100644
index 00000000..8bd03fc4
--- /dev/null
+++ b/snautofollow/lang/eo/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "Ĝidatigis StatusNet AutoFollow agordojn.";
+$a->strings["StatusNet AutoFollow Settings"] = "StatusNet AutoFollow agordoj";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Aŭtomate sekvu ĉiujn StatusNet sekvantojn/menciantojn.";
+$a->strings["Submit"] = "Sendi";
diff --git a/snautofollow/lang/es/messages.po b/snautofollow/lang/es/messages.po
new file mode 100644
index 00000000..afd88331
--- /dev/null
+++ b/snautofollow/lang/es/messages.po
@@ -0,0 +1,36 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+# Translators:
+# Albert, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: friendica\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-27 05:01-0500\n"
+"PO-Revision-Date: 2016-11-17 22:37+0000\n"
+"Last-Translator: Albert\n"
+"Language-Team: Spanish (http://www.transifex.com/Friendica/friendica/language/es/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: es\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr "Ajustes de StatusNet AutoFollow actualizados."
+
+#: snautofollow.php:56
+msgid "StatusNet AutoFollow Settings"
+msgstr "Ajustes de StatusNet AutoFollow"
+
+#: snautofollow.php:58
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr "Seguir automáticamente a cualquiera que te siga/mencione en StatusNet"
+
+#: snautofollow.php:64
+msgid "Submit"
+msgstr "Enviar"
diff --git a/snautofollow/lang/es/strings.php b/snautofollow/lang/es/strings.php
new file mode 100644
index 00000000..2800360d
--- /dev/null
+++ b/snautofollow/lang/es/strings.php
@@ -0,0 +1,11 @@
+strings["StatusNet AutoFollow settings updated."] = "Ajustes de StatusNet AutoFollow actualizados.";
+$a->strings["StatusNet AutoFollow Settings"] = "Ajustes de StatusNet AutoFollow";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Seguir automáticamente a cualquiera que te siga/mencione en StatusNet";
+$a->strings["Submit"] = "Enviar";
diff --git a/snautofollow/lang/fr/strings.php b/snautofollow/lang/fr/strings.php
new file mode 100644
index 00000000..f6791ffa
--- /dev/null
+++ b/snautofollow/lang/fr/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "Réglages de suivi automatique sur StatusNet mis à jour.";
+$a->strings["StatusNet AutoFollow Settings"] = "Réglages de suivi automatique sur StatusNet";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Suivre automatiquement les personnes qui vous suivent ou vous mentionnent sur Statusnet";
+$a->strings["Submit"] = "Envoyer";
diff --git a/snautofollow/lang/is/strings.php b/snautofollow/lang/is/strings.php
new file mode 100644
index 00000000..73eda760
--- /dev/null
+++ b/snautofollow/lang/is/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "";
+$a->strings["StatusNet AutoFollow Settings"] = "";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "";
+$a->strings["Submit"] = "Senda inn";
diff --git a/snautofollow/lang/it/messages.po b/snautofollow/lang/it/messages.po
new file mode 100644
index 00000000..b7b8d3f8
--- /dev/null
+++ b/snautofollow/lang/it/messages.po
@@ -0,0 +1,36 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+# Translators:
+# fabrixxm , 2014-2015
+msgid ""
+msgstr ""
+"Project-Id-Version: friendica\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-27 05:01-0500\n"
+"PO-Revision-Date: 2015-08-31 10:23+0000\n"
+"Last-Translator: fabrixxm \n"
+"Language-Team: Italian (http://www.transifex.com/Friendica/friendica/language/it/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: it\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr "Impostazioni \"StatusNet AutoFollow\" aggiornate."
+
+#: snautofollow.php:56
+msgid "StatusNet AutoFollow Settings"
+msgstr "Impostazioni StatusNet AutoFollow"
+
+#: snautofollow.php:58
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr "Segui automanticamente chiunque da StatusNet ti segua o ti menzioni"
+
+#: snautofollow.php:64
+msgid "Submit"
+msgstr "Invia"
diff --git a/snautofollow/lang/it/strings.php b/snautofollow/lang/it/strings.php
new file mode 100644
index 00000000..b6fab060
--- /dev/null
+++ b/snautofollow/lang/it/strings.php
@@ -0,0 +1,11 @@
+strings["StatusNet AutoFollow settings updated."] = "Impostazioni \"StatusNet AutoFollow\" aggiornate.";
+$a->strings["StatusNet AutoFollow Settings"] = "Impostazioni StatusNet AutoFollow";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Segui automanticamente chiunque da StatusNet ti segua o ti menzioni";
+$a->strings["Submit"] = "Invia";
diff --git a/snautofollow/lang/nb-no/strings.php b/snautofollow/lang/nb-no/strings.php
new file mode 100644
index 00000000..6a25c730
--- /dev/null
+++ b/snautofollow/lang/nb-no/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "";
+$a->strings["StatusNet AutoFollow Settings"] = "";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "";
+$a->strings["Submit"] = "Lagre";
diff --git a/snautofollow/lang/pl/strings.php b/snautofollow/lang/pl/strings.php
new file mode 100644
index 00000000..8ffa6d98
--- /dev/null
+++ b/snautofollow/lang/pl/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "";
+$a->strings["StatusNet AutoFollow Settings"] = "";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "";
+$a->strings["Submit"] = "Potwierdź";
diff --git a/snautofollow/lang/pt-br/strings.php b/snautofollow/lang/pt-br/strings.php
new file mode 100644
index 00000000..c932de9a
--- /dev/null
+++ b/snautofollow/lang/pt-br/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "";
+$a->strings["StatusNet AutoFollow Settings"] = "";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "";
+$a->strings["Submit"] = "Enviar";
diff --git a/snautofollow/lang/ro/messages.po b/snautofollow/lang/ro/messages.po
new file mode 100644
index 00000000..108b6c87
--- /dev/null
+++ b/snautofollow/lang/ro/messages.po
@@ -0,0 +1,35 @@
+# ADDON snautofollow
+# Copyright (C)
+# This file is distributed under the same license as the Friendica snautofollow addon package.
+#
+#
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: friendica\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-23 14:45+0200\n"
+"PO-Revision-Date: 2014-07-08 12:07+0000\n"
+"Last-Translator: Arian - Cazare Muncitori \n"
+"Language-Team: Romanian (Romania) (http://www.transifex.com/projects/p/friendica/language/ro_RO/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: ro_RO\n"
+"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n"
+
+#: snautofollow.php:32
+msgid "StatusNet AutoFollow settings updated."
+msgstr "Configurări StatusNet AutoFollow actualizate."
+
+#: snautofollow.php:56 snautofollow.php:60
+msgid "StatusNet AutoFollow"
+msgstr "StatusNet AutoFollow"
+
+#: snautofollow.php:64
+msgid "Automatically follow any StatusNet followers/mentioners"
+msgstr "Urmărește automat orice susținător/pe cei ce vă menționează pe StatusNet"
+
+#: snautofollow.php:70
+msgid "Save Settings"
+msgstr "Salvare Configurări"
diff --git a/snautofollow/lang/ro/strings.php b/snautofollow/lang/ro/strings.php
new file mode 100644
index 00000000..b8fb967f
--- /dev/null
+++ b/snautofollow/lang/ro/strings.php
@@ -0,0 +1,11 @@
+19)||(($n%100==0)&&($n!=0)))?2:1));;
+}}
+;
+$a->strings["StatusNet AutoFollow settings updated."] = "Configurări StatusNet AutoFollow actualizate.";
+$a->strings["StatusNet AutoFollow"] = "StatusNet AutoFollow";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "Urmărește automat orice susținător/pe cei ce vă menționează pe StatusNet";
+$a->strings["Save Settings"] = "Salvare Configurări";
diff --git a/snautofollow/lang/ru/strings.php b/snautofollow/lang/ru/strings.php
new file mode 100644
index 00000000..2f7dec45
--- /dev/null
+++ b/snautofollow/lang/ru/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "";
+$a->strings["StatusNet AutoFollow Settings"] = "";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "";
+$a->strings["Submit"] = "Подтвердить";
diff --git a/snautofollow/lang/sv/strings.php b/snautofollow/lang/sv/strings.php
new file mode 100644
index 00000000..3ec569a7
--- /dev/null
+++ b/snautofollow/lang/sv/strings.php
@@ -0,0 +1,3 @@
+strings["Submit"] = "Spara";
diff --git a/snautofollow/lang/zh-cn/strings.php b/snautofollow/lang/zh-cn/strings.php
new file mode 100644
index 00000000..1c704242
--- /dev/null
+++ b/snautofollow/lang/zh-cn/strings.php
@@ -0,0 +1,6 @@
+strings["StatusNet AutoFollow settings updated."] = "StatusNet自动关注设置更新了。";
+$a->strings["StatusNet AutoFollow Settings"] = "StatusNet自动关注设置";
+$a->strings["Automatically follow any StatusNet followers/mentioners"] = "自动关注所有的StatusGet关注者/提及";
+$a->strings["Submit"] = "提交";
diff --git a/snautofollow/snautofollow.css b/snautofollow/snautofollow.css
new file mode 100644
index 00000000..243ecaa8
--- /dev/null
+++ b/snautofollow/snautofollow.css
@@ -0,0 +1,14 @@
+
+
+
+#snautofollow-label {
+ float: left;
+ width: 200px;
+ margin-bottom: 25px;
+}
+
+#snautofollow-checkbox {
+ float: left;
+}
+
+
diff --git a/snautofollow/snautofollow.php b/snautofollow/snautofollow.php
new file mode 100644
index 00000000..2d953d5b
--- /dev/null
+++ b/snautofollow/snautofollow.php
@@ -0,0 +1,71 @@
+
+ * Status: Unsupported
+ */
+
+
+function snautofollow_install() {
+
+ register_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
+ register_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
+
+}
+
+
+function snautofollow_uninstall() {
+ unregister_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
+ unregister_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
+
+}
+
+
+function snautofollow_settings_post($a,$post) {
+ if(! local_user() || (! x($_POST,'snautofollow-submit')))
+ return;
+
+ set_pconfig(local_user(),'system','ostatus_autofriend',intval($_POST['snautofollow']));
+ info( t('StatusNet AutoFollow settings updated.') . EOL);
+}
+
+function snautofollow_settings(&$a,&$s) {
+
+ if(! local_user())
+ return;
+
+ /* Add our stylesheet to the page so we can make our settings look nice */
+
+ $a->page['htmlhead'] .= '' . "\r\n";
+
+ /* Get the current state of our config variable */
+
+ $snautofollow = get_pconfig(local_user(),'system','ostatus_autofriend');
+ if($snautofollow === false)
+ $snautofollow = false;
+
+ $snautofollow_checked = (($snautofollow) ? ' checked="checked" ' : '');
+
+
+ /* Add some HTML to the existing form */
+
+ $s .= '';
+ $s .= '' . t('StatusNet AutoFollow') . '
';
+ $s .= '';
+ $s .= '';
+
+}
diff --git a/startpage/startpage.php b/startpage/startpage.php
index b0ee04cb..e0d822ac 100644
--- a/startpage/startpage.php
+++ b/startpage/startpage.php
@@ -4,10 +4,9 @@
* Description: Set a preferred page to load on login from home page
* Version: 1.0
* Author: Mike Macgirvin
- *
+ *
*/
-use Friendica\Core\PConfig;
function startpage_install() {
register_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
@@ -28,9 +27,12 @@ function startpage_home_init($a, $b) {
if(! local_user())
return;
- $page = PConfig::get(local_user(),'startpage','startpage');
+ $page = get_pconfig(local_user(),'startpage','startpage');
if(strlen($page)) {
- goaway($page);
+ $slash = ((strpos($page,'/') === 0) ? true : false);
+ if(stristr($page,'://'))
+ goaway($page);
+ goaway($a->get_baseurl() . (($slash) ? '' : '/') . $page);
}
return;
}
@@ -48,13 +50,13 @@ function startpage_settings_post($a,$post) {
if(! local_user())
return;
if($_POST['startpage-submit'])
- PConfig::set(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage'])));
+ set_pconfig(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage'])));
}
/**
*
- * Called from the Plugin Setting form.
+ * Called from the Plugin Setting form.
* Add our own settings info to the page.
*
*/
@@ -72,7 +74,7 @@ function startpage_settings(&$a,&$s) {
/* Get the current state of our config variable */
- $page = PConfig::get(local_user(),'startpage','startpage');
+ $page = get_pconfig(local_user(),'startpage','startpage');
/* Add some HTML to the existing form */
diff --git a/statistics_json/README.md b/statistics_json/README.md
new file mode 100644
index 00000000..a4d542cf
--- /dev/null
+++ b/statistics_json/README.md
@@ -0,0 +1,14 @@
+With this addon you send some information about your friendica node to the
+[the-federation.info](http://the-federation.info) page. It collects
+statistical data about building blocks of *The Federation*, the decentralized
+federated social networks (Diaspora*, ~friendica and red#matrix).
+
+The information includes
+
+* the name of your node
+* friendica version
+* registration policy
+* total number of users of that node and the active user number
+* total number of public postings
+* which plugins are activated (only Facebook, Twitter, Tumblr and Wordpress
+ will be displayed on the statistics page at the moment).
diff --git a/statistics_json/lang/C/messages.po b/statistics_json/lang/C/messages.po
new file mode 100644
index 00000000..e69de29b
diff --git a/statistics_json/statistics_json.php b/statistics_json/statistics_json.php
new file mode 100644
index 00000000..2bd2f41f
--- /dev/null
+++ b/statistics_json/statistics_json.php
@@ -0,0 +1,148 @@
+
+ * Status: Unsupported
+ */
+
+function statistics_json_install() {
+ register_hook('cron', 'addon/statistics_json/statistics_json.php', 'statistics_json_cron');
+}
+
+
+function statistics_json_uninstall() {
+ unregister_hook('cron', 'addon/statistics_json/statistics_json.php', 'statistics_json_cron');
+}
+
+function statistics_json_module() {}
+
+function statistics_json_plugin_enabled($plugin) {
+ $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin);
+ return((bool)(count($r) > 0));
+}
+
+function statistics_json_init() {
+ global $a;
+
+ $statistics = array(
+ "name" => $a->config["sitename"],
+ "network" => FRIENDICA_PLATFORM,
+ "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION,
+ "registrations_open" => ($a->config['register_policy'] != 0),
+ "total_users" => get_config('statistics_json','total_users'),
+ "active_users_halfyear" => get_config('statistics_json','active_users_halfyear'),
+ "active_users_monthly" => get_config('statistics_json','active_users_monthly'),
+ "local_posts" => get_config('statistics_json','local_posts')
+ );
+
+ $statistics["services"] = array();
+ $statistics["services"]["appnet"] = statistics_json_plugin_enabled("appnet");
+ $statistics["services"]["blogger"] = statistics_json_plugin_enabled("blogger");
+ $statistics["services"]["buffer"] = statistics_json_plugin_enabled("buffer");
+ $statistics["services"]["dreamwidth"] = statistics_json_plugin_enabled("dwpost");
+ $statistics["services"]["facebook"] = statistics_json_plugin_enabled("fbpost");
+ $statistics["services"]["gnusocial"] = statistics_json_plugin_enabled("statusnet");
+ $statistics["services"]["googleplus"] = statistics_json_plugin_enabled("gpluspost");
+ $statistics["services"]["libertree"] = statistics_json_plugin_enabled("libertree");
+ $statistics["services"]["livejournal"] = statistics_json_plugin_enabled("ljpost");
+ $statistics["services"]["pumpio"] = statistics_json_plugin_enabled("pumpio");
+ $statistics["services"]["twitter"] = statistics_json_plugin_enabled("twitter");
+ $statistics["services"]["tumblr"] = statistics_json_plugin_enabled("tumblr");
+ $statistics["services"]["wordpress"] = statistics_json_plugin_enabled("wppost");
+
+ $statistics["appnet"] = $statistics["services"]["appnet"];
+ $statistics["blogger"] = $statistics["services"]["blogger"];
+ $statistics["buffer"] = $statistics["services"]["buffer"];
+ $statistics["dreamwidth"] = $statistics["services"]["dreamwidth"];
+ $statistics["facebook"] = $statistics["services"]["facebook"];
+ $statistics["gnusocial"] = $statistics["services"]["gnusocial"];
+ $statistics["googleplus"] = $statistics["services"]["googleplus"];
+ $statistics["libertree"] = $statistics["services"]["libertree"];
+ $statistics["livejournal"] = $statistics["services"]["livejournal"];
+ $statistics["pumpio"] = $statistics["services"]["pumpio"];
+ $statistics["twitter"] = $statistics["services"]["twitter"];
+ $statistics["tumblr"] = $statistics["services"]["tumblr"];
+ $statistics["wordpress"] = $statistics["services"]["wordpress"];
+
+ header("Content-Type: application/json");
+ echo json_encode($statistics);
+ logger("statistics_init: printed ".print_r($statistics, true));
+ killme();
+}
+
+function statistics_json_cron($a,$b) {
+ $last = get_config('statistics_json','last_calucation');
+
+ if($last) {
+ // Calculate every 24 hours
+ $next = $last + (24 * 60 * 60);
+ if($next > time()) {
+ logger('statistics_json_cron: calculation intervall not reached');
+ return;
+ }
+ }
+ logger('statistics_json_cron: cron_start');
+
+
+ $users = q("SELECT profile.*, `user`.`login_date`, `lastitem`.`lastitem_date`
+ FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
+ FROM `item`
+ WHERE `item`.`type` = 'wall'
+ GROUP BY `item`.`uid`) AS `lastitem`
+ RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`, `contact`, `profile`
+ WHERE
+ `user`.`uid` = `contact`.`uid` AND `profile`.`uid` = `user`.`uid`
+ AND `profile`.`is-default` AND (`profile`.`publish` OR `profile`.`net-publish`)
+ AND `user`.`verified` AND `contact`.`self`
+ AND NOT `user`.`blocked`
+ AND NOT `user`.`account_removed`
+ AND NOT `user`.`account_expired`");
+
+ if (is_array($users)) {
+ $total_users = count($users);
+ $active_users_halfyear = 0;
+ $active_users_monthly = 0;
+
+ $halfyear = time() - (180 * 24 * 60 * 60);
+ $month = time() - (30 * 24 * 60 * 60);
+
+ foreach ($users AS $user) {
+ if ((strtotime($user['login_date']) > $halfyear) ||
+ (strtotime($user['lastitem_date']) > $halfyear))
+ ++$active_users_halfyear;
+
+ if ((strtotime($user['login_date']) > $month) ||
+ (strtotime($user['lastitem_date']) > $month))
+ ++$active_users_monthly;
+
+ }
+ set_config('statistics_json','total_users', $total_users);
+ logger('statistics_json_cron: total_users: '.$total_users, LOGGER_DEBUG);
+
+ set_config('statistics_json','active_users_halfyear', $active_users_halfyear);
+ set_config('statistics_json','active_users_monthly', $active_users_monthly);
+ }
+
+ $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE `wall` AND `uid` != 0 AND `id` = `parent` AND left(body, 6) != '[share'");
+
+ if (!is_array($posts))
+ $local_posts = -1;
+ else
+ $local_posts = $posts[0]["local_posts"];
+
+ set_config('statistics_json','local_posts', $local_posts);
+
+ logger('statistics_json_cron: local_posts: '.$local_posts, LOGGER_DEBUG);
+
+ // Now trying to register
+ $url = "http://the-federation.info/register/".$a->get_hostname();
+ logger('statistics_json_cron: registering url: '.$url, LOGGER_DEBUG);
+ $ret = fetch_url($url);
+ logger('statistics_json_cron: registering answer: '.$ret, LOGGER_DEBUG);
+
+ logger('statistics_json_cron: cron_end');
+ set_config('statistics_json','last_calucation', time());
+}
diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php
index 9158052a..a004a624 100644
--- a/statusnet/statusnet.php
+++ b/statusnet/statusnet.php
@@ -1,5 +1,4 @@
get($this->host . 'statusnet/config.json');
+ return $config->site->textlimit;
+ }
+ function accessTokenURL() { return $this->host.'oauth/access_token'; }
+ function authenticateURL() { return $this->host.'oauth/authenticate'; }
+ function authorizeURL() { return $this->host.'oauth/authorize'; }
+ function requestTokenURL() { return $this->host.'oauth/request_token'; }
+ function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
+ parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
+ $this->host = $apipath;
+ }
+ /**
+ * Make an HTTP request
+ *
+ * @return API results
+ *
+ * Copied here from the twitteroauth library and complemented by applying the proxy settings of friendica
+ */
+ function http($url, $method, $postfields = NULL) {
+ $this->http_info = array();
+ $ci = curl_init();
+ /* Curl settings */
+ $prx = get_config('system','proxy');
+ if(strlen($prx)) {
+ curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
+ curl_setopt($ci, CURLOPT_PROXY, $prx);
+ $prxusr = get_config('system','proxyuser');
+ if(strlen($prxusr))
+ curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
+ }
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
+ curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
-class StatusNetOAuth extends TwitterOAuth
-{
- function get_maxlength()
- {
- $config = $this->get($this->host . 'statusnet/config.json');
- return $config->site->textlimit;
+ switch ($method) {
+ case 'POST':
+ curl_setopt($ci, CURLOPT_POST, TRUE);
+ if (!empty($postfields)) {
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
-
- function accessTokenURL()
- {
- return $this->host . 'oauth/access_token';
+ break;
+ case 'DELETE':
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
+ if (!empty($postfields)) {
+ $url = "{$url}?{$postfields}";
}
+ }
- function authenticateURL()
- {
- return $this->host . 'oauth/authenticate';
- }
-
- function authorizeURL()
- {
- return $this->host . 'oauth/authorize';
- }
-
- function requestTokenURL()
- {
- return $this->host . 'oauth/request_token';
- }
-
- function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
- {
- parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
- $this->host = $apipath;
- }
-
- /**
- * Make an HTTP request
- *
- * @return API results
- *
- * Copied here from the twitteroauth library and complemented by applying the proxy settings of friendica
- */
- function http($url, $method, $postfields = NULL)
- {
- $this->http_info = [];
- $ci = curl_init();
- /* Curl settings */
- $prx = Config::get('system', 'proxy');
- if (strlen($prx)) {
- curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ci, CURLOPT_PROXY, $prx);
- $prxusr = Config::get('system', 'proxyuser');
- if (strlen($prxusr)) {
- curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
- }
- }
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']);
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
- curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']);
- curl_setopt($ci, CURLOPT_HEADER, FALSE);
-
- switch ($method) {
- case 'POST':
- curl_setopt($ci, CURLOPT_POST, TRUE);
- if (!empty($postfields)) {
- curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
- }
- break;
- case 'DELETE':
- curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
- if (!empty($postfields)) {
- $url = "{$url}?{$postfields}";
- }
- }
-
- curl_setopt($ci, CURLOPT_URL, $url);
- $response = curl_exec($ci);
- $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
- $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
- $this->url = $url;
- curl_close($ci);
- return $response;
- }
+ curl_setopt($ci, CURLOPT_URL, $url);
+ $response = curl_exec($ci);
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
+ $this->url = $url;
+ curl_close ($ci);
+ return $response;
+ }
}
-function statusnet_install()
-{
+function statusnet_install() {
// we need some hooks, for the configuration and for sending tweets
register_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
register_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
register_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
register_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
- register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
+ register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
- register_hook('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
+ register_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
logger("installed GNU Social");
}
-function statusnet_uninstall()
-{
+
+function statusnet_uninstall() {
unregister_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
unregister_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
unregister_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
unregister_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
- unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
+ unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
unregister_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
unregister_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
- unregister_hook('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
+ unregister_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
// old setting - remove only
unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
unregister_hook('plugin_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
unregister_hook('plugin_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
+
}
-function statusnet_check_item_notification(App $a, &$notification_data)
-{
- $notification_data["profiles"][] = PConfig::get($notification_data["uid"], 'statusnet', 'own_url');
+function statusnet_check_item_notification($a, &$notification_data) {
+ $notification_data["profiles"][] = get_pconfig($notification_data["uid"], 'statusnet', 'own_url');
}
-function statusnet_jot_nets(App $a, &$b)
-{
- if (!local_user()) {
+function statusnet_jot_nets(&$a,&$b) {
+ if(! local_user())
return;
- }
- $statusnet_post = PConfig::get(local_user(), 'statusnet', 'post');
- if (intval($statusnet_post) == 1) {
- $statusnet_defpost = PConfig::get(local_user(), 'statusnet', 'post_by_default');
+ $statusnet_post = get_pconfig(local_user(),'statusnet','post');
+ if(intval($statusnet_post) == 1) {
+ $statusnet_defpost = get_pconfig(local_user(),'statusnet','post_by_default');
$selected = ((intval($statusnet_defpost) == 1) ? ' checked="checked" ' : '');
$b .= ' '
. t('Post to GNU Social') . '';
}
}
-function statusnet_settings_post(App $a, $post)
-{
- if (!local_user()) {
+function statusnet_settings_post ($a,$post) {
+ if(! local_user())
return;
- }
// don't check GNU Social settings if GNU Social submit button is not clicked
- if (!x($_POST, 'statusnet-submit')) {
+ if (!x($_POST,'statusnet-submit'))
return;
- }
if (isset($_POST['statusnet-disconnect'])) {
- /* * *
+ /***
* if the GNU Social-disconnect checkbox is set, clear the GNU Social configuration
*/
- PConfig::delete(local_user(), 'statusnet', 'consumerkey');
- PConfig::delete(local_user(), 'statusnet', 'consumersecret');
- PConfig::delete(local_user(), 'statusnet', 'post');
- PConfig::delete(local_user(), 'statusnet', 'post_by_default');
- PConfig::delete(local_user(), 'statusnet', 'oauthtoken');
- PConfig::delete(local_user(), 'statusnet', 'oauthsecret');
- PConfig::delete(local_user(), 'statusnet', 'baseapi');
- PConfig::delete(local_user(), 'statusnet', 'lastid');
- PConfig::delete(local_user(), 'statusnet', 'mirror_posts');
- PConfig::delete(local_user(), 'statusnet', 'import');
- PConfig::delete(local_user(), 'statusnet', 'create_user');
- PConfig::delete(local_user(), 'statusnet', 'own_id');
+ del_pconfig(local_user(), 'statusnet', 'consumerkey');
+ del_pconfig(local_user(), 'statusnet', 'consumersecret');
+ del_pconfig(local_user(), 'statusnet', 'post');
+ del_pconfig(local_user(), 'statusnet', 'post_by_default');
+ del_pconfig(local_user(), 'statusnet', 'oauthtoken');
+ del_pconfig(local_user(), 'statusnet', 'oauthsecret');
+ del_pconfig(local_user(), 'statusnet', 'baseapi');
+ del_pconfig(local_user(), 'statusnet', 'lastid');
+ del_pconfig(local_user(), 'statusnet', 'mirror_posts');
+ del_pconfig(local_user(), 'statusnet', 'import');
+ del_pconfig(local_user(), 'statusnet', 'create_user');
+ del_pconfig(local_user(), 'statusnet', 'own_id');
} else {
- if (isset($_POST['statusnet-preconf-apiurl'])) {
- /* * *
- * If the user used one of the preconfigured GNU Social server credentials
- * use them. All the data are available in the global config.
- * Check the API Url never the less and blame the admin if it's not working ^^
- */
- $globalsn = Config::get('statusnet', 'sites');
- foreach ($globalsn as $asn) {
- if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
- $apibase = $asn['apiurl'];
- $c = fetch_url($apibase . 'statusnet/version.xml');
- if (strlen($c) > 0) {
- PConfig::set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
- PConfig::set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
- PConfig::set(local_user(), 'statusnet', 'baseapi', $asn['apiurl']);
- //PConfig::set(local_user(), 'statusnet', 'application_name', $asn['applicationname'] );
- } else {
- notice(t('Please contact your site administrator.
The provided API URL is not valid.') . EOL . $asn['apiurl'] . EOL);
- }
- }
- }
- goaway('settings/connectors');
- } else {
- if (isset($_POST['statusnet-consumersecret'])) {
- // check if we can reach the API of the GNU Social server
- // we'll check the API Version for that, if we don't get one we'll try to fix the path but will
- // resign quickly after this one try to fix the path ;-)
- $apibase = $_POST['statusnet-baseapi'];
- $c = fetch_url($apibase . 'statusnet/version.xml');
+ if (isset($_POST['statusnet-preconf-apiurl'])) {
+ /***
+ * If the user used one of the preconfigured GNU Social server credentials
+ * use them. All the data are available in the global config.
+ * Check the API Url never the less and blame the admin if it's not working ^^
+ */
+ $globalsn = get_config('statusnet', 'sites');
+ foreach ( $globalsn as $asn) {
+ if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl'] ) {
+ $apibase = $asn['apiurl'];
+ $c = fetch_url( $apibase . 'statusnet/version.xml' );
if (strlen($c) > 0) {
- // ok the API path is correct, let's save the settings
- PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
- PConfig::set(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
- PConfig::set(local_user(), 'statusnet', 'baseapi', $apibase);
- //PConfig::set(local_user(), 'statusnet', 'application_name', $_POST['statusnet-applicationname'] );
+ set_pconfig(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey'] );
+ set_pconfig(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret'] );
+ set_pconfig(local_user(), 'statusnet', 'baseapi', $asn['apiurl'] );
+ //set_pconfig(local_user(), 'statusnet', 'application_name', $asn['applicationname'] );
} else {
- // the API path is not correct, maybe missing trailing / ?
- $apibase = $apibase . '/';
- $c = fetch_url($apibase . 'statusnet/version.xml');
- if (strlen($c) > 0) {
- // ok the API path is now correct, let's save the settings
- PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
- PConfig::set(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
- PConfig::set(local_user(), 'statusnet', 'baseapi', $apibase);
- } else {
- // still not the correct API base, let's do noting
- notice(t('We could not contact the GNU Social API with the Path you entered.') . EOL);
- }
- }
- goaway('settings/connectors');
- } else {
- if (isset($_POST['statusnet-pin'])) {
- // if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
- $api = PConfig::get(local_user(), 'statusnet', 'baseapi');
- $ckey = PConfig::get(local_user(), 'statusnet', 'consumerkey');
- $csecret = PConfig::get(local_user(), 'statusnet', 'consumersecret');
- // the token and secret for which the PIN was generated were hidden in the settings
- // form as token and token2, we need a new connection to GNU Social using these token
- // and secret to request a Access Token with the PIN
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']);
- $token = $connection->getAccessToken($_POST['statusnet-pin']);
- // ok, now that we have the Access Token, save them in the user config
- PConfig::set(local_user(), 'statusnet', 'oauthtoken', $token['oauth_token']);
- PConfig::set(local_user(), 'statusnet', 'oauthsecret', $token['oauth_token_secret']);
- PConfig::set(local_user(), 'statusnet', 'post', 1);
- PConfig::set(local_user(), 'statusnet', 'post_taglinks', 1);
- // reload the Addon Settings page, if we don't do it see Bug #42
- goaway('settings/connectors');
- } else {
- // if no PIN is supplied in the POST variables, the user has changed the setting
- // to post a dent for every new __public__ posting to the wall
- PConfig::set(local_user(), 'statusnet', 'post', intval($_POST['statusnet-enable']));
- PConfig::set(local_user(), 'statusnet', 'post_by_default', intval($_POST['statusnet-default']));
- PConfig::set(local_user(), 'statusnet', 'mirror_posts', intval($_POST['statusnet-mirror']));
- PConfig::set(local_user(), 'statusnet', 'import', intval($_POST['statusnet-import']));
- PConfig::set(local_user(), 'statusnet', 'create_user', intval($_POST['statusnet-create_user']));
-
- if (!intval($_POST['statusnet-mirror']))
- PConfig::delete(local_user(), 'statusnet', 'lastid');
-
- info(t('GNU Social settings updated.') . EOL);
+ notice( t('Please contact your site administrator.
The provided API URL is not valid.').EOL.$asn['apiurl'].EOL );
}
}
}
- }
-}
+ goaway($a->get_baseurl().'/settings/connectors');
+ } else {
+ if (isset($_POST['statusnet-consumersecret'])) {
+ // check if we can reach the API of the GNU Social server
+ // we'll check the API Version for that, if we don't get one we'll try to fix the path but will
+ // resign quickly after this one try to fix the path ;-)
+ $apibase = $_POST['statusnet-baseapi'];
+ $c = fetch_url( $apibase . 'statusnet/version.xml' );
+ if (strlen($c) > 0) {
+ // ok the API path is correct, let's save the settings
+ set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
+ set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
+ set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
+ //set_pconfig(local_user(), 'statusnet', 'application_name', $_POST['statusnet-applicationname'] );
+ } else {
+ // the API path is not correct, maybe missing trailing / ?
+ $apibase = $apibase . '/';
+ $c = fetch_url( $apibase . 'statusnet/version.xml' );
+ if (strlen($c) > 0) {
+ // ok the API path is now correct, let's save the settings
+ set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
+ set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
+ set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
+ } else {
+ // still not the correct API base, let's do noting
+ notice( t('We could not contact the GNU Social API with the Path you entered.').EOL );
+ }
+ }
+ goaway($a->get_baseurl().'/settings/connectors');
+ } else {
+ if (isset($_POST['statusnet-pin'])) {
+ // if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
+ $api = get_pconfig(local_user(), 'statusnet', 'baseapi');
+ $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' );
+ $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' );
+ // the token and secret for which the PIN was generated were hidden in the settings
+ // form as token and token2, we need a new connection to GNU Social using these token
+ // and secret to request a Access Token with the PIN
+ $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']);
+ $token = $connection->getAccessToken( $_POST['statusnet-pin'] );
+ // ok, now that we have the Access Token, save them in the user config
+ set_pconfig(local_user(),'statusnet', 'oauthtoken', $token['oauth_token']);
+ set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']);
+ set_pconfig(local_user(),'statusnet', 'post', 1);
+ set_pconfig(local_user(),'statusnet', 'post_taglinks', 1);
+ // reload the Addon Settings page, if we don't do it see Bug #42
+ goaway($a->get_baseurl().'/settings/connectors');
+ } else {
+ // if no PIN is supplied in the POST variables, the user has changed the setting
+ // to post a dent for every new __public__ posting to the wall
+ set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable']));
+ set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default']));
+ set_pconfig(local_user(), 'statusnet', 'mirror_posts', intval($_POST['statusnet-mirror']));
+ set_pconfig(local_user(), 'statusnet', 'import', intval($_POST['statusnet-import']));
+ set_pconfig(local_user(), 'statusnet', 'create_user', intval($_POST['statusnet-create_user']));
-function statusnet_settings(App $a, &$s)
-{
- if (!local_user()) {
+ if (!intval($_POST['statusnet-mirror']))
+ del_pconfig(local_user(),'statusnet','lastid');
+
+ info( t('GNU Social settings updated.') . EOL);
+ }}}}
+}
+function statusnet_settings(&$a,&$s) {
+ if(! local_user())
return;
- }
$a->page['htmlhead'] .= '' . "\r\n";
- /* * *
+ /***
* 1) Check that we have a base api url and a consumer key & secret
* 2) If no OAuthtoken & stuff is present, generate button to get some
* allow the user to cancel the connection process at this step
* 3) Checkbox for "Send public notices (respect size limitation)
*/
- $api = PConfig::get(local_user(), 'statusnet', 'baseapi');
- $ckey = PConfig::get(local_user(), 'statusnet', 'consumerkey');
- $csecret = PConfig::get(local_user(), 'statusnet', 'consumersecret');
- $otoken = PConfig::get(local_user(), 'statusnet', 'oauthtoken');
- $osecret = PConfig::get(local_user(), 'statusnet', 'oauthsecret');
- $enabled = PConfig::get(local_user(), 'statusnet', 'post');
+ $api = get_pconfig(local_user(), 'statusnet', 'baseapi');
+ $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey');
+ $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret');
+ $otoken = get_pconfig(local_user(), 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig(local_user(), 'statusnet', 'oauthsecret');
+ $enabled = get_pconfig(local_user(), 'statusnet', 'post');
$checked = (($enabled) ? ' checked="checked" ' : '');
- $defenabled = PConfig::get(local_user(), 'statusnet', 'post_by_default');
+ $defenabled = get_pconfig(local_user(),'statusnet','post_by_default');
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
- $mirrorenabled = PConfig::get(local_user(), 'statusnet', 'mirror_posts');
+ $mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
- $import = PConfig::get(local_user(), 'statusnet', 'import');
- $importselected = ["", "", ""];
+ $import = get_pconfig(local_user(),'statusnet','import');
+ $importselected = array("", "", "");
$importselected[$import] = ' selected="selected"';
- //$importenabled = PConfig::get(local_user(),'statusnet','import');
+ //$importenabled = get_pconfig(local_user(),'statusnet','import');
//$importchecked = (($importenabled) ? ' checked="checked" ' : '');
- $create_userenabled = PConfig::get(local_user(), 'statusnet', 'create_user');
+ $create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
$css = (($enabled) ? '' : '-disabled');
$s .= '';
- $s .= '
' . t('GNU Social Import/Export/Mirror') . '
';
+ $s .= '
'. t('GNU Social Import/Export/Mirror').'
';
$s .= '';
$s .= '';
}
-function statusnet_post_local(App $a, &$b)
-{
+
+function statusnet_post_local(&$a, &$b) {
if ($b['edit']) {
return;
}
@@ -479,11 +437,11 @@ function statusnet_post_local(App $a, &$b)
return;
}
- $statusnet_post = PConfig::get(local_user(), 'statusnet', 'post');
- $statusnet_enable = (($statusnet_post && x($_REQUEST, 'statusnet_enable')) ? intval($_REQUEST['statusnet_enable']) : 0);
+ $statusnet_post = get_pconfig(local_user(),'statusnet','post');
+ $statusnet_enable = (($statusnet_post && x($_REQUEST,'statusnet_enable')) ? intval($_REQUEST['statusnet_enable']) : 0);
// if API is used, default to the chosen settings
- if ($b['api_source'] && intval(PConfig::get(local_user(), 'statusnet', 'post_by_default'))) {
+ if ($b['api_source'] && intval(get_pconfig(local_user(),'statusnet','post_by_default'))) {
$statusnet_enable = 1;
}
@@ -498,61 +456,64 @@ function statusnet_post_local(App $a, &$b)
$b['postopts'] .= 'statusnet';
}
-function statusnet_action(App $a, $uid, $pid, $action)
-{
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
+function statusnet_action($a, $uid, $pid, $action) {
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
- logger("statusnet_action '" . $action . "' ID: " . $pid, LOGGER_DATA);
+ logger("statusnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
switch ($action) {
case "delete":
- $result = $connection->post("statuses/destroy/" . $pid);
+ $result = $connection->post("statuses/destroy/".$pid);
break;
case "like":
- $result = $connection->post("favorites/create/" . $pid);
+ $result = $connection->post("favorites/create/".$pid);
break;
case "unlike":
- $result = $connection->post("favorites/destroy/" . $pid);
+ $result = $connection->post("favorites/destroy/".$pid);
break;
}
- logger("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
+ logger("statusnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
}
-function statusnet_post_hook(App $a, &$b)
-{
+function statusnet_post_hook(&$a,&$b) {
+
/**
* Post to GNU Social
*/
- if (!PConfig::get($b["uid"], 'statusnet', 'import')) {
- if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
+
+ if (!get_pconfig($b["uid"],'statusnet','import')) {
+ if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return;
}
- $api = PConfig::get($b["uid"], 'statusnet', 'baseapi');
+ $api = get_pconfig($b["uid"], 'statusnet', 'baseapi');
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
- if ($b['parent'] != $b['id']) {
- logger("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA);
+ if($b['parent'] != $b['id']) {
+ logger("statusnet_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
// Looking if its a reply to a GNU Social post
$hostlength = strlen($hostname) + 2;
- if ((substr($b["parent-uri"], 0, $hostlength) != $hostname . "::") && (substr($b["extid"], 0, $hostlength) != $hostname . "::") && (substr($b["thr-parent"], 0, $hostlength) != $hostname . "::")) {
- logger("statusnet_post_hook: no GNU Social post " . $b["parent"]);
+ if ((substr($b["parent-uri"], 0, $hostlength) != $hostname."::") && (substr($b["extid"], 0, $hostlength) != $hostname."::")
+ && (substr($b["thr-parent"], 0, $hostlength) != $hostname."::")) {
+ logger("statusnet_post_hook: no GNU Social post ".$b["parent"]);
return;
}
$r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"]));
+ WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1",
+ dbesc($b["thr-parent"]),
+ intval($b["uid"]));
- if (!count($r)) {
- logger("statusnet_post_hook: no parent found " . $b["thr-parent"]);
+ if(!count($r)) {
+ logger("statusnet_post_hook: no parent found ".$b["thr-parent"]);
return;
} else {
$iscomment = true;
@@ -564,36 +525,26 @@ function statusnet_post_hook(App $a, &$b)
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
- $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
- $nicknameplain = "@" . $nick;
+ $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
+ $nicknameplain = "@".$nick;
- logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG);
- if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) {
- $b["body"] = $nickname . " " . $b["body"];
- }
+ logger("statusnet_post_hook: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
+ if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false))
+ $b["body"] = $nickname." ".$b["body"];
- logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG);
+ logger("statusnet_post_hook: parent found ".print_r($orig_post, true), LOGGER_DEBUG);
} else {
$iscomment = false;
- if ($b['private'] || !strstr($b['postopts'], 'statusnet')) {
+ if($b['private'] || !strstr($b['postopts'],'statusnet'))
return;
- }
-
- // Dont't post if the post doesn't belong to us.
- // This is a check for forum postings
- $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
- if ($b['contact-id'] != $self['id']) {
- return;
- }
}
- if (($b['verb'] == ACTIVITY_POST) && $b['deleted']) {
+ if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
- }
- if ($b['verb'] == ACTIVITY_LIKE) {
- logger("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
+ if($b['verb'] == ACTIVITY_LIKE) {
+ logger("statusnet_post_hook: parameter 2 ".substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
if ($b['deleted'])
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
else
@@ -601,45 +552,42 @@ function statusnet_post_hook(App $a, &$b)
return;
}
- if ($b['deleted'] || ($b['created'] !== $b['edited'])) {
+ if($b['deleted'] || ($b['created'] !== $b['edited']))
return;
- }
// if posts comes from GNU Social don't send it back
- if ($b['extid'] == NETWORK_STATUSNET) {
+ if($b['extid'] == NETWORK_STATUSNET)
return;
- }
- if ($b['app'] == "StatusNet") {
+ if($b['app'] == "StatusNet")
return;
- }
logger('GNU Socialpost invoked');
- PConfig::load($b['uid'], 'statusnet');
+ load_pconfig($b['uid'], 'statusnet');
- $api = PConfig::get($b['uid'], 'statusnet', 'baseapi');
- $ckey = PConfig::get($b['uid'], 'statusnet', 'consumerkey');
- $csecret = PConfig::get($b['uid'], 'statusnet', 'consumersecret');
- $otoken = PConfig::get($b['uid'], 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($b['uid'], 'statusnet', 'oauthsecret');
+ $api = get_pconfig($b['uid'], 'statusnet', 'baseapi');
+ $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret');
+ $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret');
+
+ if($ckey && $csecret && $otoken && $osecret) {
- if ($ckey && $csecret && $otoken && $osecret) {
// If it's a repeated message from GNU Social then do a native retweet and exit
- if (statusnet_is_retweet($a, $b['uid'], $b['body'])) {
+ if (statusnet_is_retweet($a, $b['uid'], $b['body']))
return;
- }
- require_once 'include/bbcode.php';
- $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ require_once('include/bbcode.php');
+ $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent
- PConfig::set($b['uid'], 'statusnet', 'max_char', $max_char);
+ set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char);
$tempfile = "";
- require_once "include/plaintext.php";
- require_once "include/network.php";
- $msgarr = plaintext($b, $max_char, true, 7);
+ require_once("include/plaintext.php");
+ require_once("include/network.php");
+ $msgarr = plaintext($a, $b, $max_char, true, 7);
$msg = $msgarr["text"];
if (($msg == "") && isset($msgarr["title"]))
@@ -649,143 +597,136 @@ function statusnet_post_hook(App $a, &$b)
if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
if ((strlen($msgarr["url"]) > 20) &&
- ((strlen($msg . " \n" . $msgarr["url"]) > $max_char))) {
- $msg .= " \n" . short_link($msgarr["url"]);
- } else {
- $msg .= " \n" . $msgarr["url"];
- }
- } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video")) {
+ ((strlen($msg." \n".$msgarr["url"]) > $max_char)))
+ $msg .= " \n".short_link($msgarr["url"]);
+ else
+ $msg .= " \n".$msgarr["url"];
+ } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video"))
$image = $msgarr["image"];
- }
if ($image != "") {
$img_str = fetch_url($image);
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
- $postdata = ["status" => $msg, "media[]" => $tempfile];
- } else {
- $postdata = ["status" => $msg];
- }
+ $postdata = array("status" => $msg, "media[]" => $tempfile);
+ } else
+ $postdata = array("status"=>$msg);
// and now dent it :-)
- if (strlen($msg)) {
+ if(strlen($msg)) {
+
if ($iscomment) {
$postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength);
- logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG);
+ logger('statusnet_post send reply '.print_r($postdata, true), LOGGER_DEBUG);
}
// New code that is able to post pictures
- require_once "addon/statusnet/codebird.php";
+ require_once("addon/statusnet/codebird.php");
$cb = \CodebirdSN\CodebirdSN::getInstance();
$cb->setAPIEndpoint($api);
$cb->setConsumerKey($ckey, $csecret);
$cb->setToken($otoken, $osecret);
$result = $cb->statuses_update($postdata);
//$result = $dent->post('statuses/update', $postdata);
- logger('statusnet_post send, result: ' . print_r($result, true) .
- "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true));
+ logger('statusnet_post send, result: ' . print_r($result, true).
+ "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b, true)."\nPost Data: ".print_r($postdata, true));
- if ($result->source) {
- PConfig::set($b["uid"], "statusnet", "application_name", strip_tags($result->source));
- }
+ if ($result->source)
+ set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source));
if ($result->error) {
- logger('Send to GNU Social failed: "' . $result->error . '"');
+ logger('Send to GNU Social failed: "'.$result->error.'"');
} elseif ($iscomment) {
- logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
+ logger('statusnet_post: Update extid '.$result->id." for post id ".$b['id']);
q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
- dbesc($hostname . "::" . $result->id),
+ dbesc($hostname."::".$result->id),
dbesc($result->text),
intval($b['id'])
);
}
}
- if ($tempfile != "") {
+ if ($tempfile != "")
unlink($tempfile);
- }
}
}
-function statusnet_plugin_admin_post(App $a)
-{
- $sites = [];
+function statusnet_plugin_admin_post(&$a){
- foreach ($_POST['sitename'] as $id => $sitename) {
- $sitename = trim($sitename);
- $apiurl = trim($_POST['apiurl'][$id]);
- if (!(substr($apiurl, -1) == '/')) {
- $apiurl = $apiurl . '/';
- }
- $secret = trim($_POST['secret'][$id]);
- $key = trim($_POST['key'][$id]);
+ $sites = array();
+
+ foreach($_POST['sitename'] as $id=>$sitename){
+ $sitename=trim($sitename);
+ $apiurl=trim($_POST['apiurl'][$id]);
+ if (! (substr($apiurl, -1)=='/'))
+ $apiurl=$apiurl.'/';
+ $secret=trim($_POST['secret'][$id]);
+ $key=trim($_POST['key'][$id]);
//$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'][$id])):'');
- if ($sitename != "" &&
- $apiurl != "" &&
- $secret != "" &&
- $key != "" &&
- !x($_POST['delete'][$id])) {
+ if ($sitename!="" &&
+ $apiurl!="" &&
+ $secret!="" &&
+ $key!="" &&
+ !x($_POST['delete'][$id])){
- $sites[] = [
- 'sitename' => $sitename,
- 'apiurl' => $apiurl,
- 'consumersecret' => $secret,
- 'consumerkey' => $key,
- //'applicationname' => $applicationname
- ];
+ $sites[] = Array(
+ 'sitename' => $sitename,
+ 'apiurl' => $apiurl,
+ 'consumersecret' => $secret,
+ 'consumerkey' => $key,
+ //'applicationname' => $applicationname
+ );
}
}
- $sites = Config::set('statusnet', 'sites', $sites);
+ $sites = set_config('statusnet','sites', $sites);
+
}
-function statusnet_plugin_admin(App $a, &$o)
-{
- $sites = Config::get('statusnet', 'sites');
- $sitesform = [];
- if (is_array($sites)) {
- foreach ($sites as $id => $s) {
- $sitesform[] = [
- 'sitename' => ["sitename[$id]", "Site name", $s['sitename'], ""],
- 'apiurl' => ["apiurl[$id]", "Api url", $s['apiurl'], t("Base API Path \x28remember the trailing /\x29")],
- 'secret' => ["secret[$id]", "Secret", $s['consumersecret'], ""],
- 'key' => ["key[$id]", "Key", $s['consumerkey'], ""],
+function statusnet_plugin_admin(&$a, &$o){
+
+ $sites = get_config('statusnet','sites');
+ $sitesform=array();
+ if (is_array($sites)){
+ foreach($sites as $id=>$s){
+ $sitesform[] = Array(
+ 'sitename' => Array("sitename[$id]", "Site name", $s['sitename'], ""),
+ 'apiurl' => Array("apiurl[$id]", "Api url", $s['apiurl'], t("Base API Path \x28remember the trailing /\x29") ),
+ 'secret' => Array("secret[$id]", "Secret", $s['consumersecret'], ""),
+ 'key' => Array("key[$id]", "Key", $s['consumerkey'], ""),
//'applicationname' => Array("applicationname[$id]", "Application name", $s['applicationname'], ""),
- 'delete' => ["delete[$id]", "Delete", False, "Check to delete this preset"],
- ];
+ 'delete' => Array("delete[$id]", "Delete", False , "Check to delete this preset"),
+ );
}
}
/* empty form to add new site */
$id++;
- $sitesform[] = [
- 'sitename' => ["sitename[$id]", t("Site name"), "", ""],
- 'apiurl' => ["apiurl[$id]", "Api url", "", t("Base API Path \x28remember the trailing /\x29")],
- 'secret' => ["secret[$id]", t("Consumer Secret"), "", ""],
- 'key' => ["key[$id]", t("Consumer Key"), "", ""],
+ $sitesform[] = Array(
+ 'sitename' => Array("sitename[$id]", t("Site name"), "", ""),
+ 'apiurl' => Array("apiurl[$id]", "Api url", "", t("Base API Path \x28remember the trailing /\x29") ),
+ 'secret' => Array("secret[$id]", t("Consumer Secret"), "", ""),
+ 'key' => Array("key[$id]", t("Consumer Key"), "", ""),
//'applicationname' => Array("applicationname[$id]", t("Application name"), "", ""),
- ];
+ );
- $t = get_markup_template("admin.tpl", "addon/statusnet/");
- $o = replace_macros($t, [
+ $t = get_markup_template( "admin.tpl", "addon/statusnet/" );
+ $o = replace_macros($t, array(
'$submit' => t('Save Settings'),
'$sites' => $sitesform,
- ]);
+ ));
}
-function statusnet_prepare_body(App $a, &$b)
-{
- if ($b["item"]["network"] != NETWORK_STATUSNET) {
- return;
- }
+function statusnet_prepare_body(&$a,&$b) {
+ if ($b["item"]["network"] != NETWORK_STATUSNET)
+ return;
- if ($b["preview"]) {
- $max_char = PConfig::get(local_user(), 'statusnet', 'max_char');
- if (intval($max_char) == 0) {
+ if ($b["preview"]) {
+ $max_char = get_pconfig(local_user(),'statusnet','max_char');
+ if (intval($max_char) == 0)
$max_char = 140;
- }
- require_once "include/plaintext.php";
- $item = $b["item"];
- $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"];
+ require_once("include/plaintext.php");
+ $item = $b["item"];
+ $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
$r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@@ -793,48 +734,44 @@ function statusnet_prepare_body(App $a, &$b)
dbesc($item["thr-parent"]),
intval(local_user()));
- if (count($r)) {
- $orig_post = $r[0];
+ if(count($r)) {
+ $orig_post = $r[0];
//$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]";
//$nicknameplain = "@".$orig_post["contact_nick"];
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
- $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
- $nicknameplain = "@" . $nick;
+ $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
+ $nicknameplain = "@".$nick;
- if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false)) {
- $item["body"] = $nickname . " " . $item["body"];
- }
- }
+ if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
+ $item["body"] = $nickname." ".$item["body"];
+ }
- $msgarr = plaintext($item, $max_char, true, 7);
- $msg = $msgarr["text"];
- if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
- $msg .= " " . $msgarr["url"];
- }
+ $msgarr = plaintext($a, $item, $max_char, true, 7);
+ $msg = $msgarr["text"];
- if (isset($msgarr["image"])) {
- $msg .= " " . $msgarr["image"];
- }
+ if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
+ $msg .= " ".$msgarr["url"];
- $b['html'] = nl2br(htmlspecialchars($msg));
- }
+ if (isset($msgarr["image"]))
+ $msg .= " ".$msgarr["image"];
+
+ $b['html'] = nl2br(htmlspecialchars($msg));
+ }
}
-function statusnet_cron(App $a, $b)
-{
- $last = Config::get('statusnet', 'last_poll');
+function statusnet_cron($a,$b) {
+ $last = get_config('statusnet','last_poll');
- $poll_interval = intval(Config::get('statusnet', 'poll_interval'));
- if (!$poll_interval) {
+ $poll_interval = intval(get_config('statusnet','poll_interval'));
+ if(! $poll_interval)
$poll_interval = STATUSNET_DEFAULT_POLL_INTERVAL;
- }
- if ($last) {
+ if($last) {
$next = $last + ($poll_interval * 60);
- if ($next > time()) {
+ if($next > time()) {
logger('statusnet: poll intervall not reached');
return;
}
@@ -842,188 +779,171 @@ function statusnet_cron(App $a, $b)
logger('statusnet: cron_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
- if (count($r)) {
- foreach ($r as $rr) {
- logger('statusnet: fetching for user ' . $rr['uid']);
+ if(count($r)) {
+ foreach($r as $rr) {
+ logger('statusnet: fetching for user '.$rr['uid']);
statusnet_fetchtimeline($a, $rr['uid']);
}
}
- $abandon_days = intval(Config::get('system', 'account_abandon_days'));
- if ($abandon_days < 1) {
+ $abandon_days = intval(get_config('system','account_abandon_days'));
+ if ($abandon_days < 1)
$abandon_days = 0;
- }
$abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
- if (count($r)) {
- foreach ($r as $rr) {
+ if(count($r)) {
+ foreach($r as $rr) {
if ($abandon_days != 0) {
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
if (!count($user)) {
- logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
+ logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
continue;
}
}
- logger('statusnet: importing timeline from user ' . $rr['uid']);
+ logger('statusnet: importing timeline from user '.$rr['uid']);
statusnet_fetchhometimeline($a, $rr["uid"], $rr["v"]);
}
}
logger('statusnet: cron_end');
- Config::set('statusnet', 'last_poll', time());
+ set_config('statusnet','last_poll', time());
}
-function statusnet_fetchtimeline(App $a, $uid)
-{
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
- $lastid = PConfig::get($uid, 'statusnet', 'lastid');
+function statusnet_fetchtimeline($a, $uid) {
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
+ $lastid = get_pconfig($uid, 'statusnet', 'lastid');
- require_once 'mod/item.php';
- require_once 'include/items.php';
+ require_once('mod/item.php');
+ require_once('include/items.php');
// get the application name for the SN app
// 1st try personal config, then system config and fallback to the
// hostname of the node if neither one is set.
- $application_name = PConfig::get($uid, 'statusnet', 'application_name');
- if ($application_name == "") {
- $application_name = Config::get('statusnet', 'application_name');
- }
- if ($application_name == "") {
+ $application_name = get_pconfig( $uid, 'statusnet', 'application_name');
+ if ($application_name == "")
+ $application_name = get_config('statusnet', 'application_name');
+ if ($application_name == "")
$application_name = $a->get_hostname();
- }
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
- $parameters = ["exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false];
+ $parameters = array("exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false);
$first_time = ($lastid == "");
- if ($lastid <> "") {
+ if ($lastid <> "")
$parameters["since_id"] = $lastid;
- }
$items = $connection->get('statuses/user_timeline', $parameters);
- if (!is_array($items)) {
+ if (!is_array($items))
return;
- }
$posts = array_reverse($items);
if (count($posts)) {
- foreach ($posts as $post) {
- if ($post->id > $lastid)
- $lastid = $post->id;
+ foreach ($posts as $post) {
+ if ($post->id > $lastid)
+ $lastid = $post->id;
- if ($first_time) {
- continue;
+ if ($first_time)
+ continue;
+
+ if ($post->source == "activity")
+ continue;
+
+ if (is_object($post->retweeted_status))
+ continue;
+
+ if ($post->in_reply_to_status_id != "")
+ continue;
+
+ if (!stristr($post->source, $application_name)) {
+ $_SESSION["authenticated"] = true;
+ $_SESSION["uid"] = $uid;
+
+ unset($_REQUEST);
+ $_REQUEST["type"] = "wall";
+ $_REQUEST["api_source"] = true;
+ $_REQUEST["profile_uid"] = $uid;
+ //$_REQUEST["source"] = "StatusNet";
+ $_REQUEST["source"] = $post->source;
+ $_REQUEST["extid"] = NETWORK_STATUSNET;
+
+ if (isset($post->id)) {
+ $_REQUEST['message_id'] = item_new_uri($a->get_hostname(), $uid, NETWORK_STATUSNET.":".$post->id);
}
- if ($post->source == "activity") {
- continue;
- }
+ //$_REQUEST["date"] = $post->created_at;
- if (is_object($post->retweeted_status)) {
- continue;
- }
+ $_REQUEST["title"] = "";
- if ($post->in_reply_to_status_id != "") {
- continue;
- }
+ $_REQUEST["body"] = add_page_info_to_body($post->text, true);
+ if (is_string($post->place->name))
+ $_REQUEST["location"] = $post->place->name;
- if (!stristr($post->source, $application_name)) {
- $_SESSION["authenticated"] = true;
- $_SESSION["uid"] = $uid;
+ if (is_string($post->place->full_name))
+ $_REQUEST["location"] = $post->place->full_name;
- unset($_REQUEST);
- $_REQUEST["type"] = "wall";
- $_REQUEST["api_source"] = true;
- $_REQUEST["profile_uid"] = $uid;
- //$_REQUEST["source"] = "StatusNet";
- $_REQUEST["source"] = $post->source;
- $_REQUEST["extid"] = NETWORK_STATUSNET;
+ if (is_array($post->geo->coordinates))
+ $_REQUEST["coord"] = $post->geo->coordinates[0]." ".$post->geo->coordinates[1];
- if (isset($post->id)) {
- $_REQUEST['message_id'] = item_new_uri($a->get_hostname(), $uid, NETWORK_STATUSNET . ":" . $post->id);
- }
+ if (is_array($post->coordinates->coordinates))
+ $_REQUEST["coord"] = $post->coordinates->coordinates[1]." ".$post->coordinates->coordinates[0];
- //$_REQUEST["date"] = $post->created_at;
+ //print_r($_REQUEST);
+ if ($_REQUEST["body"] != "") {
+ logger('statusnet: posting for user '.$uid);
- $_REQUEST["title"] = "";
-
- $_REQUEST["body"] = add_page_info_to_body($post->text, true);
- if (is_string($post->place->name)) {
- $_REQUEST["location"] = $post->place->name;
- }
-
- if (is_string($post->place->full_name)) {
- $_REQUEST["location"] = $post->place->full_name;
- }
-
- if (is_array($post->geo->coordinates)) {
- $_REQUEST["coord"] = $post->geo->coordinates[0] . " " . $post->geo->coordinates[1];
- }
-
- if (is_array($post->coordinates->coordinates)) {
- $_REQUEST["coord"] = $post->coordinates->coordinates[1] . " " . $post->coordinates->coordinates[0];
- }
-
- //print_r($_REQUEST);
- if ($_REQUEST["body"] != "") {
- logger('statusnet: posting for user ' . $uid);
-
- item_post($a);
- }
+ item_post($a);
}
}
+ }
}
- PConfig::set($uid, 'statusnet', 'lastid', $lastid);
+ set_pconfig($uid, 'statusnet', 'lastid', $lastid);
}
-function statusnet_address($contact)
-{
+function statusnet_address($contact) {
$hostname = normalise_link($contact->statusnet_profile_url);
$nickname = $contact->screen_name;
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $contact->statusnet_profile_url);
- $address = $contact->screen_name . "@" . $hostname;
+ $address = $contact->screen_name."@".$hostname;
- return $address;
+ return($address);
}
-function statusnet_fetch_contact($uid, $contact, $create_user)
-{
- if ($contact->statusnet_profile_url == "") {
- return -1;
- }
+function statusnet_fetch_contact($uid, $contact, $create_user) {
+ if ($contact->statusnet_profile_url == "")
+ return(-1);
- GContact::update(["url" => $contact->statusnet_profile_url,
- "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url,
- "name" => $contact->name, "nick" => $contact->screen_name,
- "location" => $contact->location, "about" => $contact->description,
- "addr" => statusnet_address($contact), "generation" => 3]);
+ update_gcontact(array("url" => $contact->statusnet_profile_url,
+ "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url,
+ "name" => $contact->name, "nick" => $contact->screen_name,
+ "location" => $contact->location, "about" => $contact->description,
+ "addr" => statusnet_address($contact), "generation" => 3));
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1",
+ intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
- if (!count($r) && !$create_user) {
- return 0;
- }
+ if(!count($r) && !$create_user)
+ return(0);
if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
- logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
- return -1;
+ logger("statusnet_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
+ return(-1);
}
- if (!count($r)) {
+ if(!count($r)) {
// create contact record
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
@@ -1053,15 +973,23 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
intval($uid),
dbesc(NETWORK_STATUSNET));
- if (!count($r)) {
- return false;
+ if(! count($r))
+ return(false);
+
+ $contact_id = $r[0]['id'];
+
+ $g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
+ intval($uid)
+ );
+
+ if($g && intval($g[0]['def_gid'])) {
+ require_once('include/group.php');
+ group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
}
- $contact_id = $r[0]['id'];
+ require_once("Photo.php");
- Group::addMember(User::getDefaultGroup($uid), $contact_id);
-
- $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $contact_id);
+ $photos = import_profile_photo($contact->profile_image_url,$uid,$contact_id);
q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s',
@@ -1076,14 +1004,19 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
);
} else {
// update profile photos once every two weeks as we have no notification of when they change.
+
//$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
- $update_photo = ($r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours'));
+ $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
// check that we have all the photos, this has been known to fail on occasion
- if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
- logger("statusnet_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG);
- $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']);
+ if((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
+
+ logger("statusnet_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG);
+
+ require_once("Photo.php");
+
+ $photos = import_profile_photo($contact->profile_image_url, $uid, $r[0]['id']);
q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s',
@@ -1117,18 +1050,17 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
}
}
- return $r[0]["id"];
+ return($r[0]["id"]);
}
-function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
-{
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
+function statusnet_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
- require_once "addon/statusnet/codebird.php";
+ require_once("addon/statusnet/codebird.php");
$cb = \Codebird\Codebird::getInstance();
$cb->setConsumerKey($ckey, $csecret);
@@ -1137,44 +1069,40 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if(count($r)) {
$self = $r[0];
- } else {
+ } else
return;
- }
- $parameters = [];
+ $parameters = array();
- if ($screen_name != "") {
+ if ($screen_name != "")
$parameters["screen_name"] = $screen_name;
- }
- if ($user_id != "") {
+ if ($user_id != "")
$parameters["user_id"] = $user_id;
- }
// Fetching user data
$user = $cb->users_show($parameters);
- if (!is_object($user)) {
+ if (!is_object($user))
return;
- }
$contact_id = statusnet_fetch_contact($uid, $user, true);
return $contact_id;
}
-function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact)
-{
- require_once "include/html2bbcode.php";
+function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existing_contact) {
+
+ require_once("include/html2bbcode.php");
logger("statusnet_createpost: start", LOGGER_DEBUG);
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
- $postarray = [];
+ $postarray = array();
$postarray['network'] = NETWORK_STATUSNET;
$postarray['gravity'] = 0;
$postarray['uid'] = $uid;
@@ -1183,31 +1111,29 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
if (is_object($post->retweeted_status)) {
$content = $post->retweeted_status;
statusnet_fetch_contact($uid, $content->user, false);
- } else {
+ } else
$content = $post;
- }
- $postarray['uri'] = $hostname . "::" . $content->id;
+ $postarray['uri'] = $hostname."::".$content->id;
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($postarray['uri']),
intval($uid)
- );
+ );
- if (count($r)) {
- return [];
- }
+ if (count($r))
+ return(array());
$contactid = 0;
if ($content->in_reply_to_status_id != "") {
- $parent = $hostname . "::" . $content->in_reply_to_status_id;
+ $parent = $hostname."::".$content->in_reply_to_status_id;
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent),
intval($uid)
- );
+ );
if (count($r)) {
$postarray['thr-parent'] = $r[0]["uri"];
$postarray['parent-uri'] = $r[0]["parent-uri"];
@@ -1217,7 +1143,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent),
intval($uid)
- );
+ );
if (count($r)) {
$postarray['thr-parent'] = $r[0]['uri'];
$postarray['parent-uri'] = $r[0]['parent-uri'];
@@ -1231,21 +1157,20 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
}
// Is it me?
- $own_url = PConfig::get($uid, 'statusnet', 'own_url');
+ $own_url = get_pconfig($uid, 'statusnet', 'own_url');
if ($content->user->id == $own_url) {
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if(count($r)) {
$contactid = $r[0]["id"];
- $postarray['owner-name'] = $r[0]["name"];
+ $postarray['owner-name'] = $r[0]["name"];
$postarray['owner-link'] = $r[0]["url"];
- $postarray['owner-avatar'] = $r[0]["photo"];
- } else {
- return [];
- }
+ $postarray['owner-avatar'] = $r[0]["photo"];
+ } else
+ return(array());
}
// Don't create accounts of people who just comment something
$create_user = false;
@@ -1260,11 +1185,10 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$postarray['owner-link'] = $post->user->statusnet_profile_url;
$postarray['owner-avatar'] = $post->user->profile_image_url;
}
- if (($contactid == 0) && !$only_existing_contact) {
+ if(($contactid == 0) && !$only_existing_contact)
$contactid = $self['id'];
- } elseif ($contactid <= 0) {
- return [];
- }
+ elseif ($contactid <= 0)
+ return(array());
$postarray['contact-id'] = $contactid;
@@ -1275,9 +1199,9 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$postarray['author-avatar'] = $content->user->profile_image_url;
// To-Do: Maybe unreliable? Can the api be entered without trailing "/"?
- $hostname = str_replace("/api/", "/notice/", PConfig::get($uid, 'statusnet', 'baseapi'));
+ $hostname = str_replace("/api/", "/notice/", get_pconfig($uid, 'statusnet', 'baseapi'));
- $postarray['plink'] = $hostname . $content->id;
+ $postarray['plink'] = $hostname.$content->id;
$postarray['app'] = strip_tags($content->source);
if ($content->user->protected) {
@@ -1291,92 +1215,99 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
$postarray['body'] = $converted["body"];
$postarray['tag'] = $converted["tags"];
- $postarray['created'] = datetime_convert('UTC', 'UTC', $content->created_at);
- $postarray['edited'] = datetime_convert('UTC', 'UTC', $content->created_at);
+ $postarray['created'] = datetime_convert('UTC','UTC',$content->created_at);
+ $postarray['edited'] = datetime_convert('UTC','UTC',$content->created_at);
- if (is_string($content->place->name)) {
+ if (is_string($content->place->name))
$postarray["location"] = $content->place->name;
- }
- if (is_string($content->place->full_name)) {
+ if (is_string($content->place->full_name))
$postarray["location"] = $content->place->full_name;
- }
- if (is_array($content->geo->coordinates)) {
- $postarray["coord"] = $content->geo->coordinates[0] . " " . $content->geo->coordinates[1];
- }
+ if (is_array($content->geo->coordinates))
+ $postarray["coord"] = $content->geo->coordinates[0]." ".$content->geo->coordinates[1];
- if (is_array($content->coordinates->coordinates)) {
- $postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0];
- }
+ if (is_array($content->coordinates->coordinates))
+ $postarray["coord"] = $content->coordinates->coordinates[1]." ".$content->coordinates->coordinates[0];
+ /*if (is_object($post->retweeted_status)) {
+ $postarray['body'] = html2bbcode($post->retweeted_status->statusnet_html);
+
+ $converted = statusnet_convertmsg($a, $postarray['body'], false);
+ $postarray['body'] = $converted["body"];
+ $postarray['tag'] = $converted["tags"];
+
+ statusnet_fetch_contact($uid, $post->retweeted_status->user, false);
+
+ // Let retweets look like wall-to-wall posts
+ $postarray['author-name'] = $post->retweeted_status->user->name;
+ $postarray['author-link'] = $post->retweeted_status->user->statusnet_profile_url;
+ $postarray['author-avatar'] = $post->retweeted_status->user->profile_image_url;
+ }*/
logger("statusnet_createpost: end", LOGGER_DEBUG);
-
- return $postarray;
+ return($postarray);
}
-function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarray)
-{
+function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray) {
+
// This function necer worked and need cleanup
+
$user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($uid)
- );
+ );
- if (!count($user)) {
+ if(!count($user))
return;
- }
// Is it me?
- if (link_compare($user[0]["url"], $postarray['author-link'])) {
+ if (link_compare($user[0]["url"], $postarray['author-link']))
return;
- }
$own_user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid),
dbesc($own_url)
- );
+ );
- if (!count($own_user)) {
+ if(!count($own_user))
return;
- }
// Is it me from GNU Social?
- if (link_compare($own_user[0]["url"], $postarray['author-link'])) {
+ if (link_compare($own_user[0]["url"], $postarray['author-link']))
return;
- }
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
dbesc($postarray['parent-uri']),
intval($uid)
- );
+ );
- if (count($myconv)) {
- foreach ($myconv as $conv) {
+ if(count($myconv)) {
+
+ foreach($myconv as $conv) {
// now if we find a match, it means we're in this conversation
- if (!link_compare($conv['author-link'], $user[0]["url"]) && !link_compare($conv['author-link'], $own_user[0]["url"])) {
- continue;
- }
- require_once 'include/enotify.php';
+ if(!link_compare($conv['author-link'],$user[0]["url"]) && !link_compare($conv['author-link'],$own_user[0]["url"]))
+ continue;
+
+ require_once('include/enotify.php');
$conv_parent = $conv['parent'];
- notification([
- 'type' => NOTIFY_COMMENT,
+ notification(array(
+ 'type' => NOTIFY_COMMENT,
'notify_flags' => $user[0]['notify-flags'],
- 'language' => $user[0]['language'],
- 'to_name' => $user[0]['username'],
- 'to_email' => $user[0]['email'],
- 'uid' => $user[0]['uid'],
- 'item' => $postarray,
- 'link' => $a->get_baseurl() . '/display/' . urlencode(get_item_guid($top_item)),
- 'source_name' => $postarray['author-name'],
- 'source_link' => $postarray['author-link'],
+ 'language' => $user[0]['language'],
+ 'to_name' => $user[0]['username'],
+ 'to_email' => $user[0]['email'],
+ 'uid' => $user[0]['uid'],
+ 'item' => $postarray,
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
+ 'source_name' => $postarray['author-name'],
+ 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'],
- 'verb' => ACTIVITY_POST,
- 'otype' => 'item',
- 'parent' => $conv_parent,
- ]);
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'item',
+ 'parent' => $conv_parent,
+ ));
// only send one notification
break;
@@ -1384,26 +1315,25 @@ function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarr
}
}
-function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
-{
- $conversations = [];
+function statusnet_fetchhometimeline($a, $uid, $mode = 1) {
+ $conversations = array();
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
- $create_user = PConfig::get($uid, 'statusnet', 'create_user');
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
+ $create_user = get_pconfig($uid, 'statusnet', 'create_user');
// "create_user" is deactivated, since currently you cannot add users manually by now
$create_user = true;
- logger("statusnet_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Fetching for user ".$uid, LOGGER_DEBUG);
- require_once 'library/twitteroauth.php';
- require_once 'include/items.php';
+ require_once('library/twitteroauth.php');
+ require_once('include/items.php');
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
$own_contact = statusnet_fetch_own_contact($a, $uid);
@@ -1411,75 +1341,71 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
intval($own_contact),
intval($uid));
- if (count($r)) {
+ if(count($r)) {
$nick = $r[0]["nick"];
} else {
- logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user ".$uid, LOGGER_DEBUG);
return;
}
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid));
- if (count($r)) {
+ if(count($r)) {
$self = $r[0];
} else {
- logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Own contact not found for user ".$uid, LOGGER_DEBUG);
return;
}
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
intval($uid));
- if (!count($u)) {
- logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG);
+ if(!count($u)) {
+ logger("statusnet_fetchhometimeline: Own user not found for user ".$uid, LOGGER_DEBUG);
return;
}
- $parameters = ["exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true];
+ $parameters = array("exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true);
//$parameters["count"] = 200;
if ($mode == 1) {
// Fetching timeline
- $lastid = PConfig::get($uid, 'statusnet', 'lasthometimelineid');
+ $lastid = get_pconfig($uid, 'statusnet', 'lasthometimelineid');
//$lastid = 1;
$first_time = ($lastid == "");
- if ($lastid != "") {
+ if ($lastid <> "")
$parameters["since_id"] = $lastid;
- }
$items = $connection->get('statuses/home_timeline', $parameters);
if (!is_array($items)) {
- if (is_object($items) && isset($items->error)) {
+ if (is_object($items) && isset($items->error))
$errormsg = $items->error;
- } elseif (is_object($items)) {
+ elseif (is_object($items))
$errormsg = print_r($items, true);
- } elseif (is_string($items) || is_float($items) || is_int($items)) {
+ elseif (is_string($items) || is_float($items) || is_int($items))
$errormsg = $items;
- } else {
+ else
$errormsg = "Unknown error";
- }
- logger("statusnet_fetchhometimeline: Error fetching home timeline: " . $errormsg, LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Error fetching home timeline: ".$errormsg, LOGGER_DEBUG);
return;
}
$posts = array_reverse($items);
- logger("statusnet_fetchhometimeline: Fetching timeline for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Fetching timeline for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
if (count($posts)) {
foreach ($posts as $post) {
- if ($post->id > $lastid) {
+ if ($post->id > $lastid)
$lastid = $post->id;
- }
- if ($first_time) {
+ if ($first_time)
continue;
- }
if (isset($post->statusnet_conversation_id)) {
if (!isset($conversations[$post->statusnet_conversation_id])) {
@@ -1489,52 +1415,48 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
} else {
$postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true);
- if (trim($postarray['body']) == "") {
+ if (trim($postarray['body']) == "")
continue;
- }
$item = item_store($postarray);
$postarray["id"] = $item;
- logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item);
+ logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item && !function_exists("check_item_notification")) {
+ if ($item && !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
- }
}
+
}
}
- PConfig::set($uid, 'statusnet', 'lasthometimelineid', $lastid);
+ set_pconfig($uid, 'statusnet', 'lasthometimelineid', $lastid);
}
// Fetching mentions
- $lastid = PConfig::get($uid, 'statusnet', 'lastmentionid');
+ $lastid = get_pconfig($uid, 'statusnet', 'lastmentionid');
$first_time = ($lastid == "");
- if ($lastid != "") {
+ if ($lastid <> "")
$parameters["since_id"] = $lastid;
- }
$items = $connection->get('statuses/mentions_timeline', $parameters);
if (!is_array($items)) {
- logger("statusnet_fetchhometimeline: Error fetching mentions: " . print_r($items, true), LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Error fetching mentions: ".print_r($items, true), LOGGER_DEBUG);
return;
}
$posts = array_reverse($items);
- logger("statusnet_fetchhometimeline: Fetching mentions for user " . $uid . " " . sizeof($posts) . " items", LOGGER_DEBUG);
+ logger("statusnet_fetchhometimeline: Fetching mentions for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
if (count($posts)) {
foreach ($posts as $post) {
- if ($post->id > $lastid) {
+ if ($post->id > $lastid)
$lastid = $post->id;
- }
- if ($first_time) {
+ if ($first_time)
continue;
- }
$postarray = statusnet_createpost($a, $uid, $post, $self, false, false);
@@ -1544,17 +1466,16 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
$conversations[$post->statusnet_conversation_id] = $post->statusnet_conversation_id;
}
} else {
- if (trim($postarray['body']) == "") {
+ if (trim($postarray['body']) != "") {
continue;
- }
- $item = item_store($postarray);
- $postarray["id"] = $item;
+ $item = item_store($postarray);
+ $postarray["id"] = $item;
- logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item);
+ logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
- if ($item && function_exists("check_item_notification")) {
- check_item_notification($item, $uid, NOTIFY_TAGSELF);
+ if ($item && function_exists("check_item_notification"))
+ check_item_notification($item, $uid, NOTIFY_TAGSELF);
}
}
@@ -1568,8 +1489,8 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
}
if (($item != 0) && !function_exists("check_item_notification")) {
- require_once 'include/enotify.php';
- notification([
+ require_once('include/enotify.php');
+ notification(array(
'type' => NOTIFY_TAGSELF,
'notify_flags' => $u[0]['notify-flags'],
'language' => $u[0]['language'],
@@ -1577,68 +1498,67 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'],
'item' => $postarray,
- 'link' => $a->get_baseurl() . '/display/' . urlencode(get_item_guid($item)),
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'],
'verb' => ACTIVITY_TAG,
'otype' => 'item',
'parent' => $parent_id,
- ]);
+ ));
}
}
}
- PConfig::set($uid, 'statusnet', 'lastmentionid', $lastid);
+ set_pconfig($uid, 'statusnet', 'lastmentionid', $lastid);
}
-function statusnet_complete_conversation(App $a, $uid, $self, $create_user, $nick, $conversation)
-{
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
- $own_url = PConfig::get($uid, 'statusnet', 'own_url');
+function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $conversation) {
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
+ $own_url = get_pconfig($uid, 'statusnet', 'own_url');
- require_once 'library/twitteroauth.php';
+ require_once('library/twitteroauth.php');
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
$parameters["count"] = 200;
- $items = $connection->get('statusnet/conversation/' . $conversation, $parameters);
+ $items = $connection->get('statusnet/conversation/'.$conversation, $parameters);
if (is_array($items)) {
$posts = array_reverse($items);
- foreach ($posts AS $post) {
+ foreach($posts AS $post) {
$postarray = statusnet_createpost($a, $uid, $post, $self, false, false);
- if (trim($postarray['body']) == "") {
+ if (trim($postarray['body']) == "")
continue;
- }
+ //print_r($postarray);
$item = item_store($postarray);
$postarray["id"] = $item;
- logger('statusnet_complete_conversation: User ' . $self["nick"] . ' posted home timeline item ' . $item);
+ logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item && !function_exists("check_item_notification")) {
+ if ($item && !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
- }
}
}
}
-function statusnet_convertmsg(App $a, $body, $no_tags = false)
-{
- require_once "include/items.php";
- require_once "include/network.php";
+function statusnet_convertmsg($a, $body, $no_tags = false) {
- $body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism", "$1.$2.$3.$4/$5", $body);
+ require_once("include/oembed.php");
+ require_once("include/items.php");
+ require_once("include/network.php");
+
+ $body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism","$1.$2.$3.$4/$5",$body);
$URLSearchString = "^\[\]";
- $links = preg_match_all("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER);
+ $links = preg_match_all("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body,$matches,PREG_SET_ORDER);
$footer = "";
$footerurl = "";
@@ -1647,34 +1567,32 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false)
if ($links) {
foreach ($matches AS $match) {
- $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]";
+ $search = "[url=".$match[1]."]".$match[2]."[/url]";
- logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG);
+ logger("statusnet_convertmsg: expanding url ".$match[1], LOGGER_DEBUG);
$expanded_url = original_url($match[1]);
- logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG);
+ logger("statusnet_convertmsg: fetching data for ".$expanded_url, LOGGER_DEBUG);
- $oembed_data = OEmbed::fetchURL($expanded_url, true);
+ $oembed_data = oembed_fetch_url($expanded_url, true);
logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG);
- if ($type == "") {
+ if ($type == "")
$type = $oembed_data->type;
- }
-
if ($oembed_data->type == "video") {
//$body = str_replace($search, "[video]".$expanded_url."[/video]", $body);
$type = $oembed_data->type;
$footerurl = $expanded_url;
- $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
+ $footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
$body = str_replace($search, $footerlink, $body);
- } elseif (($oembed_data->type == "photo") && isset($oembed_data->url) && !$dontincludemedia) {
- $body = str_replace($search, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body);
- } elseif ($oembed_data->type != "link") {
- $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
- } else {
+ } elseif (($oembed_data->type == "photo") && isset($oembed_data->url) && !$dontincludemedia)
+ $body = str_replace($search, "[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]", $body);
+ elseif ($oembed_data->type != "link")
+ $body = str_replace($search, "[url=".$expanded_url."]".$expanded_url."[/url]", $body);
+ else {
$img_str = fetch_url($expanded_url, true, $redirects, 4);
$tempfile = tempnam(get_temppath(), "cache");
@@ -1684,150 +1602,138 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false)
if (substr($mime, 0, 6) == "image/") {
$type = "photo";
- $body = str_replace($search, "[img]" . $expanded_url . "[/img]", $body);
+ $body = str_replace($search, "[img]".$expanded_url."[/img]", $body);
} else {
$type = $oembed_data->type;
$footerurl = $expanded_url;
- $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
+ $footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
$body = str_replace($search, $footerlink, $body);
}
}
}
- if ($footerurl != "") {
+ if ($footerurl != "")
$footer = add_page_info($footerurl);
- }
if (($footerlink != "") && (trim($footer) != "")) {
$removedlink = trim(str_replace($footerlink, "", $body));
- if (($removedlink == "") || strstr($body, $removedlink)) {
+ if (($removedlink == "") || strstr($body, $removedlink))
$body = $removedlink;
- }
$body .= $footer;
}
}
- if ($no_tags) {
- return ["body" => $body, "tags" => ""];
- }
+ if ($no_tags)
+ return(array("body" => $body, "tags" => ""));
$str_tags = '';
- $cnt = preg_match_all("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- if (strlen($str_tags)) {
+ $cnt = preg_match_all("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",$body,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ if(strlen($str_tags))
$str_tags .= ',';
- }
if ($mtch[1] == "#") {
// Replacing the hash tags that are directed to the GNU Social server with internal links
- $snhash = "#[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]";
- $frdchash = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($mtch[3]) . ']' . $mtch[3] . '[/url]';
+ $snhash = "#[url=".$mtch[2]."]".$mtch[3]."[/url]";
+ $frdchash = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($mtch[3]).']'.$mtch[3].'[/url]';
$body = str_replace($snhash, $frdchash, $body);
$str_tags .= $frdchash;
- } else {
- $str_tags .= "@[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]";
- }
- // To-Do:
- // There is a problem with links with to GNU Social groups, so these links are stored with "@" like friendica groups
- //$str_tags .= $mtch[1]."[url=".$mtch[2]."]".$mtch[3]."[/url]";
+ } else
+ $str_tags .= "@[url=".$mtch[2]."]".$mtch[3]."[/url]";
+ // To-Do:
+ // There is a problem with links with to GNU Social groups, so these links are stored with "@" like friendica groups
+ //$str_tags .= $mtch[1]."[url=".$mtch[2]."]".$mtch[3]."[/url]";
}
}
- return ["body" => $body, "tags" => $str_tags];
+ return(array("body"=>$body, "tags"=>$str_tags));
+
}
-function statusnet_fetch_own_contact(App $a, $uid)
-{
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
- $own_url = PConfig::get($uid, 'statusnet', 'own_url');
+function statusnet_fetch_own_contact($a, $uid) {
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
+ $own_url = get_pconfig($uid, 'statusnet', 'own_url');
$contact_id = 0;
if ($own_url == "") {
- require_once 'library/twitteroauth.php';
+ require_once('library/twitteroauth.php');
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
// Fetching user data
$user = $connection->get('account/verify_credentials');
- PConfig::set($uid, 'statusnet', 'own_url', normalise_link($user->statusnet_profile_url));
+ set_pconfig($uid, 'statusnet', 'own_url', normalise_link($user->statusnet_profile_url));
$contact_id = statusnet_fetch_contact($uid, $user, true);
+
} else {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc($own_url));
- if (count($r)) {
+ if(count($r))
$contact_id = $r[0]["id"];
- } else {
- PConfig::delete($uid, 'statusnet', 'own_url');
- }
+ else
+ del_pconfig($uid, 'statusnet', 'own_url');
+
}
- return $contact_id;
+ return($contact_id);
}
-function statusnet_is_retweet(App $a, $uid, $body)
-{
+function statusnet_is_retweet($a, $uid, $body) {
$body = trim($body);
// Skip if it isn't a pure repeated messages
// Does it start with a share?
- if (strpos($body, "[share") > 0) {
- return false;
- }
+ if (strpos($body, "[share") > 0)
+ return(false);
// Does it end with a share?
- if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
- return false;
- }
+ if (strlen($body) > (strrpos($body, "[/share]") + 8))
+ return(false);
- $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
+ $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
// Skip if there is no shared message in there
- if ($body == $attributes) {
- return false;
- }
+ if ($body == $attributes)
+ return(false);
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "") {
+ if ($matches[1] != "")
$link = $matches[1];
- }
preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "") {
+ if ($matches[1] != "")
$link = $matches[1];
- }
- $ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
- $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
- $api = PConfig::get($uid, 'statusnet', 'baseapi');
- $otoken = PConfig::get($uid, 'statusnet', 'oauthtoken');
- $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
+ $ckey = get_pconfig($uid, 'statusnet', 'consumerkey');
+ $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
+ $api = get_pconfig($uid, 'statusnet', 'baseapi');
+ $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
+ $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
- $id = preg_replace("=https?://" . $hostname . "/notice/(.*)=ism", "$1", $link);
+ $id = preg_replace("=https?://".$hostname."/notice/(.*)=ism", "$1", $link);
- if ($id == $link) {
- return false;
- }
+ if ($id == $link)
+ return(false);
- logger('statusnet_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG);
+ logger('statusnet_is_retweet: Retweeting id '.$id.' for user '.$uid, LOGGER_DEBUG);
- $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
+ $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
- $result = $connection->post('statuses/retweet/' . $id);
+ $result = $connection->post('statuses/retweet/'.$id);
- logger('statusnet_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG);
-
- return isset($result->id);
+ logger('statusnet_is_retweet: result '.print_r($result, true), LOGGER_DEBUG);
+ return(isset($result->id));
}
diff --git a/superblock/lang/es/messages.po b/superblock/lang/es/messages.po
index 3bbdeb90..5f81fef8 100644
--- a/superblock/lang/es/messages.po
+++ b/superblock/lang/es/messages.po
@@ -4,15 +4,15 @@
#
#
# Translators:
-# Albert, 2016-2017
+# Albert, 2016
# juanman , 2017
msgid ""
msgstr ""
"Project-Id-Version: friendica\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-21 08:45+0200\n"
-"PO-Revision-Date: 2017-10-26 18:00+0000\n"
-"Last-Translator: Albert\n"
+"PO-Revision-Date: 2017-07-04 16:27+0000\n"
+"Last-Translator: juanman \n"
"Language-Team: Spanish (http://www.transifex.com/Friendica/friendica/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -22,7 +22,7 @@ msgstr ""
#: superblock.php:53 superblock.php:57
msgid "\"Superblock\""
-msgstr "«Superbloque»"
+msgstr ""
#: superblock.php:60
msgid "Comma separated profile URLS to block"
@@ -34,7 +34,7 @@ msgstr "Guardar configuración"
#: superblock.php:76
msgid "SUPERBLOCK Settings saved."
-msgstr "Ajustes de SUPERBLOQUE guardados."
+msgstr ""
#: superblock.php:148
msgid "Block Completely"
@@ -42,4 +42,4 @@ msgstr "Bloquear completamente"
#: superblock.php:168
msgid "superblock settings updated"
-msgstr "ajustes de superbloque actualizados"
+msgstr ""
diff --git a/superblock/lang/es/strings.php b/superblock/lang/es/strings.php
index 1b40975f..cb80c96e 100644
--- a/superblock/lang/es/strings.php
+++ b/superblock/lang/es/strings.php
@@ -5,9 +5,9 @@ function string_plural_select_es($n){
return ($n != 1);;
}}
;
-$a->strings["\"Superblock\""] = "«Superbloque»";
+$a->strings["\"Superblock\""] = "";
$a->strings["Comma separated profile URLS to block"] = "Perfil de URLS a bloque separado por comas";
$a->strings["Save Settings"] = "Guardar configuración";
-$a->strings["SUPERBLOCK Settings saved."] = "Ajustes de SUPERBLOQUE guardados.";
+$a->strings["SUPERBLOCK Settings saved."] = "";
$a->strings["Block Completely"] = "Bloquear completamente";
-$a->strings["superblock settings updated"] = "ajustes de superbloque actualizados";
+$a->strings["superblock settings updated"] = "";
diff --git a/superblock/superblock.php b/superblock/superblock.php
index c33c699d..c86c6aad 100644
--- a/superblock/superblock.php
+++ b/superblock/superblock.php
@@ -9,8 +9,6 @@
*
*/
-use Friendica\Core\PConfig;
-
function superblock_install() {
register_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings');
@@ -46,7 +44,7 @@ function superblock_addon_settings(&$a,&$s) {
$a->page['htmlhead'] .= '' . "\r\n";
- $words = PConfig::get(local_user(),'system','blocked');
+ $words = get_pconfig(local_user(),'system','blocked');
if(! $words) {
$words = '';
}
@@ -74,14 +72,14 @@ function superblock_addon_settings_post(&$a,&$b) {
return;
if($_POST['superblock-submit']) {
- PConfig::set(local_user(),'system','blocked',trim($_POST['superblock-words']));
+ set_pconfig(local_user(),'system','blocked',trim($_POST['superblock-words']));
info( t('SUPERBLOCK Settings saved.') . EOL);
}
}
function superblock_enotify_store(&$a,&$b) {
- $words = PConfig::get($b['uid'],'system','blocked');
+ $words = get_pconfig($b['uid'],'system','blocked');
if($words) {
$arr = explode(',',$words);
}
@@ -113,7 +111,7 @@ function superblock_conversation_start(&$a,&$b) {
if(! local_user())
return;
- $words = PConfig::get(local_user(),'system','blocked');
+ $words = get_pconfig(local_user(),'system','blocked');
if($words) {
$a->data['superblock'] = explode(',',$words);
}
@@ -158,7 +156,7 @@ function superblock_init(&$a) {
if(! local_user())
return;
- $words = PConfig::get(local_user(),'system','blocked');
+ $words = get_pconfig(local_user(),'system','blocked');
if(array_key_exists('block',$_GET) && $_GET['block']) {
if(strlen($words))
@@ -166,7 +164,7 @@ function superblock_init(&$a) {
$words .= trim($_GET['block']);
}
- PConfig::set(local_user(),'system','blocked',$words);
+ set_pconfig(local_user(),'system','blocked',$words);
info( t('superblock settings updated') . EOL );
killme();
}
diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php
index 6203f3cd..9bbeb1d8 100644
--- a/testdrive/testdrive.php
+++ b/testdrive/testdrive.php
@@ -7,8 +7,7 @@
* Author: Mike Macgirvin
*/
-use Friendica\Core\Config;
-use Friendica\Model\User;
+
function testdrive_install() {
@@ -38,7 +37,7 @@ function testdrive_register_account($a,$b) {
$uid = $b;
- $days = Config::get('testdrive','expiredays');
+ $days = get_config('testdrive','expiredays');
if(! $days)
return;
@@ -58,7 +57,7 @@ function testdrive_cron($a,$b) {
if(count($r)) {
foreach($r as $rr) {
- notification([
+ notification(array(
'uid' => $rr['uid'],
'type' => NOTIFY_SYSTEM,
'system_type' => 'testdrive_expire',
@@ -68,7 +67,7 @@ function testdrive_cron($a,$b) {
'source_name' => t('Administrator'),
'source_link' => $a->get_baseurl(),
'source_photo' => $a->get_baseurl() . '/images/person-80.jpg',
- ]);
+ ));
q("update user set expire_notification_sent = '%s' where uid = %d",
dbesc(datetime_convert()),
@@ -80,17 +79,19 @@ function testdrive_cron($a,$b) {
$r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY ");
if(count($r)) {
- foreach($r as $rr) {
- User::remove($rr['uid']);
- }
+ require_once('include/Contact.php');
+ foreach($r as $rr)
+ user_remove($rr['uid']);
+
}
+
}
function testdrive_enotify(&$a, &$b) {
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') {
$b['itemlink'] = $a->get_baseurl();
- $b['epreamble'] = $b['preamble'] = sprintf( t('Your account on %s will expire in a few days.'), Config::get('system','sitename'));
+ $b['epreamble'] = $b['preamble'] = sprintf( t('Your account on %s will expire in a few days.'), get_config('system','sitename'));
$b['subject'] = t('Your Friendica test account is about to expire.');
$b['body'] = sprintf( t("Hi %1\$s,\n\nYour test account on %2\$s will expire in less than five days. We hope you enjoyed this test drive and use this opportunity to find a permanent Friendica website for your integrated social communications. A list of public sites is available at %s/siteinfo - and for more information on setting up your own Friendica server please see the Friendica project website at http://friendica.com."), $b['params']['to_name'], "[url=".$app->config["system"]["url"]."]".$app->config["sitename"]."[/url]", get_server());
}
diff --git a/tictac/tictac.php b/tictac/tictac.php
index 99737841..1dd1ccb0 100644
--- a/tictac/tictac.php
+++ b/tictac/tictac.php
@@ -17,7 +17,7 @@ function tictac_uninstall() {
}
function tictac_app_menu($a,&$b) {
- $b['app_menu'][] = '';
+ $b['app_menu'][] = '';
}
@@ -39,7 +39,7 @@ function tictac_content(&$a) {
$dimen = $a->argv[3];
$yours = $a->argv[4];
$mine = $a->argv[5];
-
+
$yours .= $_POST['move'];
}
elseif($a->argc > 1) {
@@ -59,7 +59,7 @@ function tictac_content(&$a) {
$o .= '' . t('New game with handicap') . '
';
$o .= '' . t('Three dimensional tic-tac-toe is just like the traditional game except that it is played on multiple levels simultaneously. ');
$o .= t('In this case there are three levels. You win by getting three in a row on any level, as well as up, down, and diagonally across the different levels.');
- $o .= '
';
+ $o .= '
';
$o .= t('The handicap game disables the center position on the middle level because the player claiming this square often has an unfair advantage.');
$o .= '
';
@@ -73,11 +73,11 @@ class tictac {
private $handicap = 0;
private $yours;
private $mine;
- private $winning_play;
+ private $winning_play;
private $you;
private $me;
private $debug = 1;
- private $crosses = ['011','101','110','112','121','211'];
+ private $crosses = array('011','101','110','112','121','211');
/*
'001','010','011','012','021',
@@ -85,82 +85,82 @@ class tictac {
'201','210','211','212','221');
*/
- private $corners = [
+ private $corners = array(
'000','002','020','022',
- '200','202','220','222'];
+ '200','202','220','222');
- private $planes = [
- ['000','001','002','010','011','012','020','021','022'], // horiz 1
- ['100','101','102','110','111','112','120','121','122'], // 2
- ['200','201','202','210','211','212','220','221','222'], // 3
- ['000','010','020','100','110','120','200','210','220'], // vert left
- ['000','001','002','100','101','102','200','201','202'], // vert top
- ['002','012','022','102','112','122','202','212','222'], // vert right
- ['020','021','022','120','121','122','220','221','222'], // vert bot
- ['010','011','012','110','111','112','210','211','212'], // left vertx
- ['001','011','021','101','111','221','201','211','221'], // top vertx
- ['000','001','002','110','111','112','220','221','222'], // diag top
- ['020','021','022','110','111','112','200','201','202'], // diag bot
- ['000','010','020','101','111','121','202','212','222'], // diag left
- ['002','012','022','101','111','121','200','210','220'], // diag right
- ['002','011','020','102','111','120','202','211','220'], // diag x
- ['000','011','022','100','111','122','200','211','222'] // diag x
-
- ];
+ private $planes = array(
+ array('000','001','002','010','011','012','020','021','022'), // horiz 1
+ array('100','101','102','110','111','112','120','121','122'), // 2
+ array('200','201','202','210','211','212','220','221','222'), // 3
+ array('000','010','020','100','110','120','200','210','220'), // vert left
+ array('000','001','002','100','101','102','200','201','202'), // vert top
+ array('002','012','022','102','112','122','202','212','222'), // vert right
+ array('020','021','022','120','121','122','220','221','222'), // vert bot
+ array('010','011','012','110','111','112','210','211','212'), // left vertx
+ array('001','011','021','101','111','221','201','211','221'), // top vertx
+ array('000','001','002','110','111','112','220','221','222'), // diag top
+ array('020','021','022','110','111','112','200','201','202'), // diag bot
+ array('000','010','020','101','111','121','202','212','222'), // diag left
+ array('002','012','022','101','111','121','200','210','220'), // diag right
+ array('002','011','020','102','111','120','202','211','220'), // diag x
+ array('000','011','022','100','111','122','200','211','222') // diag x
+
+ );
- private $winner = [
- ['000','001','002'], // board 0 winners - left corner across
- ['000','010','020'], // down
- ['000','011','022'], // diag
- ['001','011','021'], // middle-top down
- ['010','011','012'], // middle-left across
- ['002','011','020'], // right-top diag
- ['002','012','022'], // right-top down
- ['020','021','022'], // bottom-left across
- ['100','101','102'], // board 1 winners
- ['100','110','120'],
- ['100','111','122'],
- ['101','111','121'],
- ['110','111','112'],
- ['102','111','120'],
- ['102','112','122'],
- ['120','121','122'],
- ['200','201','202'], // board 2 winners
- ['200','210','220'],
- ['200','211','222'],
- ['201','211','221'],
- ['210','211','212'],
- ['202','211','220'],
- ['202','212','222'],
- ['220','221','222'],
- ['000','100','200'], // top-left corner 3d
- ['000','101','202'],
- ['000','110','220'],
- ['000','111','222'],
- ['001','101','201'], // top-middle 3d
- ['001','111','221'],
- ['002','102','202'], // top-right corner 3d
- ['002','101','200'],
- ['002','112','222'],
- ['002','111','220'],
- ['010','110','210'], // left-middle 3d
- ['010','111','212'],
- ['011','111','211'], // middle-middle 3d
- ['012','112','212'], // right-middle 3d
- ['012','111','210'],
- ['020','120','220'], // bottom-left corner 3d
- ['020','110','200'],
- ['020','121','222'],
- ['020','111','202'],
- ['021','121','221'], // bottom-middle 3d
- ['021','111','201'],
- ['022','122','222'], // bottom-right corner 3d
- ['022','121','220'],
- ['022','112','202'],
- ['022','111','200']
+ private $winner = array(
+ array('000','001','002'), // board 0 winners - left corner across
+ array('000','010','020'), // down
+ array('000','011','022'), // diag
+ array('001','011','021'), // middle-top down
+ array('010','011','012'), // middle-left across
+ array('002','011','020'), // right-top diag
+ array('002','012','022'), // right-top down
+ array('020','021','022'), // bottom-left across
+ array('100','101','102'), // board 1 winners
+ array('100','110','120'),
+ array('100','111','122'),
+ array('101','111','121'),
+ array('110','111','112'),
+ array('102','111','120'),
+ array('102','112','122'),
+ array('120','121','122'),
+ array('200','201','202'), // board 2 winners
+ array('200','210','220'),
+ array('200','211','222'),
+ array('201','211','221'),
+ array('210','211','212'),
+ array('202','211','220'),
+ array('202','212','222'),
+ array('220','221','222'),
+ array('000','100','200'), // top-left corner 3d
+ array('000','101','202'),
+ array('000','110','220'),
+ array('000','111','222'),
+ array('001','101','201'), // top-middle 3d
+ array('001','111','221'),
+ array('002','102','202'), // top-right corner 3d
+ array('002','101','200'),
+ array('002','112','222'),
+ array('002','111','220'),
+ array('010','110','210'), // left-middle 3d
+ array('010','111','212'),
+ array('011','111','211'), // middle-middle 3d
+ array('012','112','212'), // right-middle 3d
+ array('012','111','210'),
+ array('020','120','220'), // bottom-left corner 3d
+ array('020','110','200'),
+ array('020','121','222'),
+ array('020','111','202'),
+ array('021','121','221'), // bottom-middle 3d
+ array('021','111','201'),
+ array('022','122','222'), // bottom-right corner 3d
+ array('022','121','220'),
+ array('022','112','202'),
+ array('022','111','200')
- ];
+ );
function __construct($dimen,$handicap,$mefirst,$yours,$mine) {
$this->dimen = 3;
@@ -209,7 +209,7 @@ class tictac {
$this->mine .= $move;
$this->me = $this->parse_moves('me');
}
- else {
+ else {
$move = $this->offensive_move();
if(strlen($move)) {
$this->mine .= $move;
@@ -231,7 +231,7 @@ class tictac {
$str = $this->mine;
if($player == 'you')
$str = $this->yours;
- $ret = [];
+ $ret = array();
while(strlen($str)) {
$ret[] = substr($str,0,3);
$str = substr($str,3);
@@ -299,7 +299,7 @@ function winning_move() {
if($this->handicap) {
$p = $this->uncontested_plane();
foreach($this->corners as $c)
- if((in_array($c,$p))
+ if((in_array($c,$p))
&& (! $this->is_yours($c)) && (! $this->is_mine($c)))
return($c);
}
@@ -320,11 +320,11 @@ function winning_move() {
if(in_array($this->me[0],$this->corners)) {
$p = $this->my_best_plane();
foreach($this->winner as $w) {
- if((in_array($w[0],$this->you))
+ if((in_array($w[0],$this->you))
|| (in_array($w[1],$this->you))
|| (in_array($w[2],$this->you)))
- continue;
- if(in_array($w[0],$this->corners)
+ continue;
+ if(in_array($w[0],$this->corners)
&& in_array($w[2],$this->corners)
&& in_array($w[0],$p) && in_array($w[2],$p)) {
if($this->me[0] == $w[0])
@@ -338,7 +338,7 @@ function winning_move() {
else {
$r = $this->get_corners($this->me);
if(count($r) > 1) {
- $w1 = []; $w2 = [];
+ $w1 = array(); $w2 = array();
foreach($this->winner as $w) {
if(in_array('111',$w))
continue;
@@ -350,13 +350,13 @@ function winning_move() {
if(count($w1) && count($w2)) {
foreach($w1 as $a) {
foreach($w2 as $b) {
- if((in_array($a[0],$this->you))
+ if((in_array($a[0],$this->you))
|| (in_array($a[1],$this->you))
|| (in_array($a[2],$this->you))
|| (in_array($b[0],$this->you))
|| (in_array($b[1],$this->you))
|| (in_array($b[2],$this->you)))
- continue;
+ continue;
if(($a[0] == $b[0]) && ! $this->is_mine($a[0])) {
return $a[0];
}
@@ -375,8 +375,8 @@ function winning_move() {
// && in_array($this->you[0],$this->corners)
// && $this->is_neighbor($this->me[0],$this->you[0])) {
- // Yuck. You foiled my plan. Since you obviously aren't playing to win,
- // I'll try again. You may keep me busy for a few rounds, but I'm
+ // Yuck. You foiled my plan. Since you obviously aren't playing to win,
+ // I'll try again. You may keep me busy for a few rounds, but I'm
// gonna' get you eventually.
// $p = $this->uncontested_plane();
@@ -388,14 +388,14 @@ function winning_move() {
// find all the winners containing my points.
- $mywinners = [];
+ $mywinners = array();
foreach($this->winner as $w)
foreach($this->me as $m)
if((in_array($m,$w)) && (! in_array($w,$mywinners)))
$mywinners[] = $w;
// find all the rules where my points are in the center.
- $trythese = [];
+ $trythese = array();
if(count($mywinners)) {
foreach($mywinners as $w) {
foreach($this->me as $m) {
@@ -406,19 +406,19 @@ function winning_move() {
}
}
- $myplanes = [];
+ $myplanes = array();
for($p = 0; $p < count($this->planes); $p ++) {
if($this->handicap && in_array('111',$this->planes[$p]))
continue;
foreach($this->me as $m)
- if((in_array($m,$this->planes[$p]))
+ if((in_array($m,$this->planes[$p]))
&& (! in_array($this->planes[$p],$myplanes)))
$myplanes[] = $this->planes[$p];
}
shuffle($myplanes);
// find all winners which share an endpoint, and which are uncontested
- $candidates = [];
+ $candidates = array();
if(count($trythese) && count($myplanes)) {
foreach($trythese as $t) {
foreach($this->winner as $w) {
@@ -436,7 +436,7 @@ function winning_move() {
// Find out if we are about to force a win.
// Looking for two winning vectors with a common endpoint
- // and where we own the middle of both - we are now going to
+ // and where we own the middle of both - we are now going to
// grab the endpoint. The game isn't yet over but we've already won.
if(count($candidates)) {
@@ -452,7 +452,7 @@ function winning_move() {
}
// find opponents planes
- $yourplanes = [];
+ $yourplanes = array();
for($p = 0; $p < count($this->planes); $p ++) {
if($this->handicap && in_array('111',$this->planes[$p]))
continue;
@@ -466,7 +466,7 @@ function winning_move() {
// We now have a list of winning strategy vectors for our second point
// Pick one that will force you into defensive mode.
// Pick a point close to you so we don't risk giving you two
- // in a row when you block us. That would force *us* into
+ // in a row when you block us. That would force *us* into
// defensive mode.
// We want: or: not:
// X|O| X| | X| |
@@ -475,41 +475,41 @@ function winning_move() {
if(count($this->you) == 1) {
foreach($this->winner as $w) {
- if(in_array($this->me[0], $w) && in_array($c[1],$w)
- && $this->uncontested_winner($w)
+ if(in_array($this->me[0], $w) && in_array($c[1],$w)
+ && $this->uncontested_winner($w)
&& $this->is_neighbor($this->you[0],$c[1])) {
return($c[1]);
- }
+ }
}
}
- }
+ }
- // You're somewhere else entirely or have made more than one move
+ // You're somewhere else entirely or have made more than one move
// - any strategy vector which puts you on the defense will have to do
foreach($candidates as $c) {
foreach($this->winner as $w) {
- if(in_array($this->me[0], $w) && in_array($c[1],$w)
+ if(in_array($this->me[0], $w) && in_array($c[1],$w)
&& $this->uncontested_winner($w)) {
return($c[1]);
- }
+ }
}
}
}
- // worst case scenario, no strategy we can play,
+ // worst case scenario, no strategy we can play,
// just find an empty space and take it
for($x = 0; $x < $this->dimen; $x ++)
for($y = 0; $y < $this->dimen; $y ++)
for($z = 0; $z < $this->dimen; $z ++)
- if((! $this->marked_yours($x,$y,$z))
+ if((! $this->marked_yours($x,$y,$z))
&& (! $this->marked_mine($x,$y,$z))) {
if($this->handicap && $x == 1 && $y == 1 && $z == 1)
continue;
return(sprintf("%d%d%d",$x,$y,$z));
}
-
+
return '';
}
@@ -540,7 +540,7 @@ function winning_move() {
}
function get_corners($a) {
- $total = [];
+ $total = array();
if(count($a))
foreach($a as $b)
if(in_array($b,$this->corners))
@@ -575,7 +575,7 @@ function winning_move() {
function my_best_plane() {
- $second_choice = [];
+ $second_choice = array();
shuffle($this->planes);
for($p = 0; $p < count($this->planes); $p ++ ) {
$contested = 0;
@@ -585,7 +585,7 @@ function winning_move() {
continue;
foreach($this->you as $m) {
if(in_array($m,$this->planes[$p]))
- $contested ++;
+ $contested ++;
}
if(! $contested)
return($this->planes[$p]);
@@ -610,8 +610,8 @@ function winning_move() {
if($this->handicap && in_array('111',$pl[$p]))
continue;
foreach($this->you as $m) {
- if(in_array($m,$pl[$p]))
- $freeplane = false;
+ if(in_array($m,$pl[$p]))
+ $freeplane = false;
}
if(! $freeplane) {
$freeplane = true;
@@ -620,7 +620,7 @@ function winning_move() {
if($freeplane)
return($pl[$p]);
}
- return [];
+ return array();
}
function fullboard() {
@@ -641,7 +641,7 @@ function winning_move() {
$bordertop = (($y != 0) ? " border-top: 2px solid #000;" : "");
$borderleft = (($z != 0) ? " border-left: 2px solid #000;" : "");
if($this->handicap && $x == 1 && $y == 1 && $z == 1)
- $o .= " ";
+ $o .= " ";
elseif($this->marked_yours($x,$y,$z))
$o .= "X ";
elseif($this->marked_mine($x,$y,$z))
diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php
index a056bd09..50530401 100644
--- a/tumblr/tumblr.php
+++ b/tumblr/tumblr.php
@@ -11,9 +11,6 @@
require_once('library/OAuth1.php');
require_once('addon/tumblr/tumblroauth/tumblroauth.php');
-use Friendica\Core\Config;
-use Friendica\Core\PConfig;
-
function tumblr_install() {
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
@@ -60,19 +57,19 @@ function tumblr_content(&$a) {
function tumblr_plugin_admin(&$a, &$o){
$t = get_markup_template( "admin.tpl", "addon/tumblr/" );
- $o = replace_macros($t, [
+ $o = replace_macros($t, array(
'$submit' => t('Save Settings'),
// name, label, value, help, [extra values]
- '$consumer_key' => ['consumer_key', t('Consumer Key'), Config::get('tumblr', 'consumer_key' ), ''],
- '$consumer_secret' => ['consumer_secret', t('Consumer Secret'), Config::get('tumblr', 'consumer_secret' ), ''],
- ]);
+ '$consumer_key' => array('consumer_key', t('Consumer Key'), get_config('tumblr', 'consumer_key' ), ''),
+ '$consumer_secret' => array('consumer_secret', t('Consumer Secret'), get_config('tumblr', 'consumer_secret' ), ''),
+ ));
}
function tumblr_plugin_admin_post(&$a){
$consumer_key = ((x($_POST,'consumer_key')) ? notags(trim($_POST['consumer_key'])) : '');
$consumer_secret = ((x($_POST,'consumer_secret')) ? notags(trim($_POST['consumer_secret'])): '');
- Config::set('tumblr','consumer_key',$consumer_key);
- Config::set('tumblr','consumer_secret',$consumer_secret);
+ set_config('tumblr','consumer_key',$consumer_key);
+ set_config('tumblr','consumer_secret',$consumer_secret);
info( t('Settings updated.'). EOL );
}
@@ -84,8 +81,8 @@ function tumblr_connect($a) {
//require_once('addon/tumblr/tumblroauth/tumblroauth.php');
// Define the needed keys
- $consumer_key = Config::get('tumblr','consumer_key');
- $consumer_secret = Config::get('tumblr','consumer_secret');
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
// The callback URL is the script that gets called after the user authenticates with tumblr
// In this example, it would be the included callback.php
@@ -134,8 +131,8 @@ function tumblr_callback($a) {
//require_once('addon/tumblr/tumblroauth/tumblroauth.php');
// Define the needed keys
- $consumer_key = Config::get('tumblr','consumer_key');
- $consumer_secret = Config::get('tumblr','consumer_secret');
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
// Once the user approves your app at Tumblr, they are sent back to this script.
// This script is passed two parameters in the URL, oauth_token (our Request Token)
@@ -161,8 +158,8 @@ function tumblr_callback($a) {
}
// What's next? Now that we have an Access Token and Secret, we can make an API call.
- PConfig::set(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
- PConfig::set(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
+ set_pconfig(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
+ set_pconfig(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
$o = t("You are now authenticated to tumblr.");
$o .= '
'.t("return to the connector page").'';
@@ -173,9 +170,9 @@ function tumblr_jot_nets(&$a,&$b) {
if(! local_user())
return;
- $tmbl_post = PConfig::get(local_user(),'tumblr','post');
+ $tmbl_post = get_pconfig(local_user(),'tumblr','post');
if(intval($tmbl_post) == 1) {
- $tmbl_defpost = PConfig::get(local_user(),'tumblr','post_by_default');
+ $tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
$b .= ' '
. t('Post to Tumblr') . '';
@@ -194,11 +191,11 @@ function tumblr_settings(&$a,&$s) {
/* Get the current state of our config variables */
- $enabled = PConfig::get(local_user(),'tumblr','post');
+ $enabled = get_pconfig(local_user(),'tumblr','post');
$checked = (($enabled) ? ' checked="checked" ' : '');
$css = (($enabled) ? '' : '-disabled');
- $def_enabled = PConfig::get(local_user(),'tumblr','post_by_default');
+ $def_enabled = get_pconfig(local_user(),'tumblr','post_by_default');
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
@@ -226,26 +223,26 @@ function tumblr_settings(&$a,&$s) {
$s .= '';
$s .= ' {{$desc}}
+ {{include file="field_input.tpl" field=$url}} + {{include file="field_input.tpl" field=$auth}} + {{include file="field_select.tpl" field=$api}} + + +"
-
+
.htmlspecialchars('')
."";
-
+
return $o;
- }
-
- }
-
+ }
+
+ }
+
echo $o;
killme();
}
-
+
?>
diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php
index 66b23a7c..21f986e0 100644
--- a/windowsphonepush/windowsphonepush.php
+++ b/windowsphonepush/windowsphonepush.php
@@ -1,58 +1,68 @@
- *
- *
+ *
+ *
* Pre-requisite: Windows Phone mobile device (at least WP 7.0)
* Friendica mobile app on Windows Phone
*
* When plugin is installed, the system calls the plugin
* name_install() function, located in 'addon/name/name.php',
* where 'name' is the name of the addon.
- * If the addon is removed from the configuration list, the
+ * If the addon is removed from the configuration list, the
* system will call the name_uninstall() function.
*
* Version history:
- * 1.1 : addon crashed on php versions >= 5.4 as of removed deprecated call-time
+ * 1.1 : addon crashed on php versions >= 5.4 as of removed deprecated call-time
* pass-by-reference used in function calls within function windowsphonepush_content
* 2.0 : adaption for supporting emphasizing new entries in app (count on tile cannot be read out,
- * so we need to retrieve counter through show_settings secondly). Provide new function for
+ * so we need to retrieve counter through show_settings secondly). Provide new function for
* calling from app to set the counter back after start (if user starts again before cronjob
* sets the counter back
* count only unseen elements which are not type=activity (likes and dislikes not seen as new elements)
*/
-use Friendica\App;
-use Friendica\Core\PConfig;
-use Friendica\Model\User;
-function windowsphonepush_install()
-{
- /* Our plugin will attach in three places.
- * The first is within cron - so the push notifications will be
+
+function windowsphonepush_install() {
+
+ /**
+ *
+ * Our plugin will attach in three places.
+ * The first is within cron - so the push notifications will be
* sent every 10 minutes (or whatever is set in crontab).
+ *
*/
+
register_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
- /* Then we'll attach into the plugin settings page, and also the
+ /**
+ *
+ * Then we'll attach into the plugin settings page, and also the
* settings post hook so that we can create and update
- * user preferences. User shall be able to activate the plugin and
+ * user preferences. User shall be able to activate the plugin and
* define whether he allows pushing first characters of item text
+ *
*/
+
register_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
register_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
logger("installed windowsphonepush");
}
-function windowsphonepush_uninstall()
-{
- /* uninstall unregisters any hooks created with register_hook
+
+function windowsphonepush_uninstall() {
+
+ /**
+ *
+ * uninstall unregisters any hooks created with register_hook
* during install. Don't delete data in table `pconfig`.
+ *
*/
+
unregister_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
unregister_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
unregister_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
@@ -60,54 +70,57 @@ function windowsphonepush_uninstall()
logger("removed windowsphonepush");
}
+
/* declare the windowsphonepush function so that /windowsphonepush url requests will land here */
-function windowsphonepush_module()
-{
+function windowsphonepush_module() {}
-}
-/* Callback from the settings post function.
+/**
+ *
+ * Callback from the settings post function.
* $post contains the $_POST array.
* We will make sure we've got a valid user account
* and if so set our configuration setting for this person.
+ *
*/
-function windowsphonepush_settings_post($a, $post)
-{
- if (!local_user() || (!x($_POST, 'windowsphonepush-submit'))) {
+function windowsphonepush_settings_post($a,$post) {
+ if(! local_user() || (! x($_POST,'windowsphonepush-submit')))
return;
- }
$enable = intval($_POST['windowsphonepush']);
- PConfig::set(local_user(), 'windowsphonepush', 'enable', $enable);
+ set_pconfig(local_user(),'windowsphonepush','enable',$enable);
- if ($enable) {
- PConfig::set(local_user(), 'windowsphonepush', 'counterunseen', 0);
+ if($enable) {
+ set_pconfig(local_user(),'windowsphonepush','counterunseen', 0);
}
- PConfig::set(local_user(), 'windowsphonepush', 'senditemtext', intval($_POST['windowsphonepush-senditemtext']));
+ set_pconfig(local_user(),'windowsphonepush','senditemtext',intval($_POST['windowsphonepush-senditemtext']));
- info(t('WindowsPhonePush settings updated.') . EOL);
+ info( t('WindowsPhonePush settings updated.') . EOL);
}
-/* Called from the Plugin Setting form.
+
+/**
+ *
+ * Called from the Plugin Setting form.
* Add our own settings info to the page.
+ *
*/
-function windowsphonepush_settings(&$a, &$s)
-{
- if (!local_user()) {
+function windowsphonepush_settings(&$a,&$s) {
+
+ if(! local_user())
return;
- }
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '' . "\r\n";
/* Get the current state of our config variables */
- $enabled = PConfig::get(local_user(), 'windowsphonepush', 'enable');
+ $enabled = get_pconfig(local_user(),'windowsphonepush','enable');
$checked_enabled = (($enabled) ? ' checked="checked" ' : '');
- $senditemtext = PConfig::get(local_user(), 'windowsphonepush', 'senditemtext');
+ $senditemtext = get_pconfig(local_user(), 'windowsphonepush', 'senditemtext');
$checked_senditemtext = (($senditemtext) ? ' checked="checked" ' : '');
- $device_url = PConfig::get(local_user(), 'windowsphonepush', 'device_url');
+ $device_url = get_pconfig(local_user(), 'windowsphonepush', 'device_url');
/* Add some HTML to the existing form */
$s .= '