X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=ifttt%2Fifttt.php;h=14add12a28a4adadf18ec7a589bd5120ab018b28;hb=8a700150cc8c0d430ca2b245618cc3aa4df375c7;hp=800294ffb04595c03da4fa4102682d9fe6d901dd;hpb=dc15e9a08037c648ff639051fb58c36db64def6b;p=friendica-addons.git
diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php
index 800294ff..14add12a 100644
--- a/ifttt/ifttt.php
+++ b/ifttt/ifttt.php
@@ -11,19 +11,22 @@ require_once 'include/items.php';
require_once 'include/text.php';
use Friendica\App;
+use Friendica\Core\Addon;
+use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
+use Friendica\Model\Item;
function ifttt_install()
{
- register_hook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
- register_hook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
+ Addon::registerHook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
+ Addon::registerHook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
}
function ifttt_uninstall()
{
- unregister_hook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
- unregister_hook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
+ Addon::unregisterHook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
+ Addon::unregisterHook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
}
function ifttt_module()
@@ -45,40 +48,40 @@ function ifttt_settings(App $a, &$s)
$key = PConfig::get(local_user(), 'ifttt', 'key');
if (!$key) {
- $key = substr(random_string(),0,20);
+ $key = random_string(20);
PConfig::set(local_user(), 'ifttt', 'key', $key);
}
$s .= '';
- $s .= '' . t('IFTTT Mirror') . ' ';
+ $s .= '' . L10n::t('IFTTT Mirror') . ' ';
$s .= ' ';
$s .= '
';
$s .= '
';
- $s .= '' . t('IFTTT Mirror') . ' ';
+ $s .= '' . L10n::t('IFTTT Mirror') . ' ';
$s .= ' ';
$s .= '
';
- $s .= '
' . t('Create an account at IFTTT . Create three Facebook recipes that are connected with Maker (In the form "if Facebook then Maker") with the following parameters:') . '
';
+ $s .= '
' . L10n::t('Create an account at IFTTT . Create three Facebook recipes that are connected with Maker (In the form "if Facebook then Maker") with the following parameters:') . '
';
$s .= '
URL ';
$s .= '
' . $a->get_baseurl() . '/ifttt/' . $a->user['nickname'] . '
';
$s .= '
Method ';
$s .= '
POST
';
$s .= '
Content Type ';
$s .= '
application/x-www-form-urlencoded
';
- $s .= '
' . t('Body for "new status message"') . ' ';
+ $s .= '
' . L10n::t('Body for "new status message"') . ' ';
$s .= '
' . htmlentities('key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '
';
- $s .= '
' . t('Body for "new photo upload"') . ' ';
+ $s .= '
' . L10n::t('Body for "new photo upload"') . ' ';
$s .= '
' . htmlentities('key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '
';
- $s .= '
' . t('Body for "new link post"') . ' ';
+ $s .= '
' . L10n::t('Body for "new link post"') . ' ';
$s .= '
' . htmlentities('key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '
';
$s .= '
';
$s .= '
';
- $s .= '' . t('Generate new key') . ' ';
+ $s .= '' . L10n::t('Generate new key') . ' ';
$s .= ' ';
$s .= '
';
- $s .= '
';
+ $s .= '
';
$s .= '
';
}
@@ -97,8 +100,8 @@ function ifttt_post(App $a)
$nickname = $a->argv[1];
- $user = dba::select('user', ['uid'], ['nickname' => $nickname], ['limit' => 1]);
- if (!DBM::is_result($user)) {
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
+ if (!DBA::isResult($user)) {
logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
return;
}
@@ -120,13 +123,13 @@ function ifttt_post(App $a)
return;
}
- $item = array();
+ $item = [];
if (isset($_REQUEST['type'])) {
$item['type'] = $_REQUEST['type'];
}
- if (!in_array($item['type'], array('status', 'link', 'photo'))) {
+ if (!in_array($item['type'], ['status', 'link', 'photo'])) {
logger('Unknown item type ' . $item['type'], LOGGER_DEBUG);
return;
}
@@ -168,7 +171,6 @@ function ifttt_message($uid, $item)
$_SESSION['uid'] = $uid;
unset($_REQUEST);
- $_REQUEST['type'] = 'wall';
$_REQUEST['api_source'] = true;
$_REQUEST['profile_uid'] = $uid;
$_REQUEST['source'] = 'IFTTT';
@@ -180,7 +182,7 @@ function ifttt_message($uid, $item)
if (strstr($item['url'], 'facebook.com')) {
$hash = hash('ripemd128', item['url']);
$_REQUEST['extid'] = NETWORK_FACEBOOK;
- $_REQUEST['message_id'] = item_new_uri($a->get_hostname(), $uid, NETWORK_FACEBOOK . ':' . $hash);
+ $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_FACEBOOK . ':' . $hash);
}
if ($item['type'] == 'link') {