diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index 42a5ba30..eebec4b0 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -34,22 +34,15 @@ */ use Friendica\App; -use Friendica\Content\Text\Markdown; use Friendica\Core\Addon; -use Friendica\Core\Cache; use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\Database\DBA; -use Friendica\Database\DBM; use Friendica\Database\DBStructure; -use Friendica\Model\Item; -use Friendica\Model\Term; -use Friendica\Module\Login; use Friendica\Network\HTTPException; -use Friendica\Util\DateTimeFormat; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Symfony\Component\ExpressionLanguage; +use Friendica\Model\Item; require_once 'boot.php'; require_once 'include/conversation.php'; @@ -117,9 +110,9 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data) $vars[str_replace('-', '_', $key)] = $value; } - $rules = Cache::get('rules_' . local_user()); + $rules = Friendica\Core\Cache::get('rules_' . local_user()); if (!isset($rules)) { - $rules = DBA::inArray(DBA::select( + $rules = dba::inArray(dba::select( 'advancedcontentfilter_rules', ['name', 'expression', 'serialized'], ['uid' => local_user(), 'active' => true] @@ -186,7 +179,7 @@ function advancedcontentfilter_init(App $a) function advancedcontentfilter_content(App $a) { if (!local_user()) { - return Login::form('/' . implode('/', $a->argv)); + return \Friendica\Module\Login::form('/' . implode('/', $a->argv)); } if ($a->argc > 0 && $a->argv[1] == 'help') { @@ -201,7 +194,7 @@ function advancedcontentfilter_content(App $a) $content = file_get_contents($help_path); - $html = Markdown::convert($content, false); + $html = \Friendica\Content\Text\Markdown::convert($content, false); $html = str_replace('code>', 'key>', $html); @@ -300,7 +293,7 @@ function advancedcontentfilter_get_rules() throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method')); } - $rules = DBA::inArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => local_user()])); + $rules = dba::inArray(dba::select('advancedcontentfilter_rules', [], ['uid' => local_user()])); return json_encode($rules); } @@ -311,7 +304,7 @@ function advancedcontentfilter_get_rules_id(ServerRequestInterface $request, Res throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method')); } - $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => local_user()]); + $rule = dba::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => local_user()]); return json_encode($rule); } @@ -339,13 +332,13 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request) } $fields['uid'] = local_user(); - $fields['created'] = DateTimeFormat::utcNow(); + $fields['created'] = \Friendica\Util\DateTimeFormat::utcNow(); - if (!DBA::insert('advancedcontentfilter_rules', $fields)) { - throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage()); + if (!dba::insert('advancedcontentfilter_rules', $fields)) { + throw new HTTPException\ServiceUnavaiableException(dba::errorMessage()); } - $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]); + $rule = dba::selectFirst('advancedcontentfilter_rules', [], ['id' => dba::lastInsertId()]); return json_encode(['message' => L10n::t('Rule successfully added'), 'rule' => $rule]); } @@ -360,7 +353,7 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.')); } - if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) { + if (!dba::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) { throw new HTTPException\NotFoundException(L10n::t('Rule doesn\'t exist or doesn\'t belong to you.')); } @@ -372,8 +365,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res throw new HTTPException\BadRequestException($e->getMessage(), 0, $e); } - if (!DBA::update('advancedcontentfilter_rules', $fields, ['id' => $args['id']])) { - throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage()); + if (!dba::update('advancedcontentfilter_rules', $fields, ['id' => $args['id']])) { + throw new HTTPException\ServiceUnavaiableException(dba::errorMessage()); } return json_encode(['message' => L10n::t('Rule successfully updated')]); @@ -389,12 +382,12 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request, throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.')); } - if (!DBA::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) { + if (!dba::exists('advancedcontentfilter_rules', ['id' => $args['id'], 'uid' => local_user()])) { throw new HTTPException\NotFoundException(L10n::t('Rule doesn\'t exist or doesn\'t belong to you.')); } - if (!DBA::delete('advancedcontentfilter_rules', ['id' => $args['id']])) { - throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage()); + if (!dba::delete('advancedcontentfilter_rules', ['id' => $args['id']])) { + throw new HTTPException\ServiceUnavaiableException(dba::errorMessage()); } return json_encode(['message' => L10n::t('Rule successfully deleted')]); @@ -414,11 +407,11 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques $params = ['order' => ['uid' => true]]; $item = Item::selectFirstForUser(local_user(), [], $condition, $params); - if (!DBM::is_result($item)) { + if (!\Friendica\Database\DBM::is_result($item)) { throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid'])); } - $tags = Term::populateTagsFromItem($item); + $tags = \Friendica\Model\Term::populateTagsFromItem($item); $item['tags'] = $tags['tags']; $item['hashtags'] = $tags['hashtags']; diff --git a/buffer/buffer.php b/buffer/buffer.php index ef95f1d7..9d14fd83 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -13,7 +13,6 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; use Friendica\Model\ItemContent; function buffer_install() { @@ -260,7 +259,7 @@ function buffer_send(App $a, &$b) // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 074cc00c..72fc1e07 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -5,18 +5,17 @@ * Version: 1.1 * Author: Fabio */ - use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Core\PConfig; use Friendica\Core\Worker; -use Friendica\Database\DBA; -use Friendica\Database\DBM; +use Friendica\Core\PConfig; +use Friendica\Util\DateTimeFormat; +use Friendica\Network\HTTPException\NotFoundException; use Friendica\Model\Contact; use Friendica\Model\Photo; -use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Database\DBM; define("CATAVATAR_SIZE", 256); @@ -78,14 +77,14 @@ function catavatar_addon_settings_post(App $a, &$s) // delete the current cached cat avatar $condition = ['uid' => local_user(), 'blocked' => false, 'account_expired' => false, 'account_removed' => false]; - $user = DBA::selectFirst('user', ['email'], $condition); + $user = dba::selectFirst('user', ['email'], $condition); $seed = PConfig::get(local_user(), 'catavatar', 'seed', md5(trim(strtolower($user['email'])))); if (!empty($_POST['catavatar-usecat'])) { $url = $a->get_baseurl() . '/catavatar/' . local_user() . '?ts=' . time(); - $self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]); if (!DBM::is_result($self)) { notice(L10n::t("The cat hadn't found itself.")); return; @@ -94,16 +93,16 @@ function catavatar_addon_settings_post(App $a, &$s) Photo::importProfilePhoto($url, local_user(), $self['id']); $condition = ['uid' => local_user(), 'contact-id' => $self['id']]; - $photo = DBA::selectFirst('photo', ['resource-id'], $condition); + $photo = dba::selectFirst('photo', ['resource-id'], $condition); if (!DBM::is_result($photo)) { notice(L10n::t('There was an error, the cat ran away.')); return; } - DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => local_user()]); + dba::update('photo', ['profile' => false], ['profile' => true, 'uid' => local_user()]); $fields = ['profile' => true, 'album' => L10n::t('Profile Photos'), 'contact-id' => 0]; - DBA::update('photo', $fields, ['uid' => local_user(), 'resource-id' => $photo['resource-id']]); + dba::update('photo', $fields, ['uid' => local_user(), 'resource-id' => $photo['resource-id']]); Photo::importProfilePhoto($url, local_user(), $self['id']); @@ -138,7 +137,7 @@ function catavatar_addon_settings_post(App $a, &$s) */ function catavatar_lookup(App $a, &$b) { - $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]); + $user = dba::selectFirst('user', ['uid'], ['email' => $b['email']]); $url = $a->get_baseurl() . '/catavatar/' . $user['uid']; switch($b['size']) { @@ -174,7 +173,7 @@ function catavatar_content(App $a) $condition = ['uid' => $uid, 'blocked' => false, 'account_expired' => false, 'account_removed' => false]; - $user = DBA::selectFirst('user', ['email'], $condition); + $user = dba::selectFirst('user', ['email'], $condition); if ($user === false) { throw new NotFoundException(); diff --git a/curweather/curweather.php b/curweather/curweather.php index edf96c3e..fe506ca3 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -25,42 +25,46 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) $cached = Cache::get('curweather'.md5($url)); $now = new DateTime(); if (!is_null($cached)) { - $cdate = PConfig::get(local_user(), 'curweather', 'last'); - $cached = unserialize($cached); - if ($cdate + $cachetime > $now->getTimestamp()) { - return $cached; - } + $cdate = PConfig::get(local_user(), 'curweather', 'last'); + $cached = unserialize($cached); + if ($cdate + $cachetime > $now->getTimestamp()) { + return $cached; + } } try { - $res = new SimpleXMLElement(Network::fetchUrl($url)); + $res = new SimpleXMLElement(Network::fetchUrl($url)); } catch (Exception $e) { - info(L10n::t('Error fetching weather data.\nError was: '.$e->getMessage())); - return false; + if (!$_SESSION['curweather_notice_shown']) { + info(L10n::t('Error fetching weather data. Error was: '.$e->getMessage())); + $_SESSION['curweather_notice_shown'] = true; + } + return false; } + unset($_SESSION['curweather_notice_shown']); if ((string)$res->temperature['unit']==='metric') { - $tunit = '°C'; - $wunit = 'm/s'; + $tunit = '°C'; + $wunit = 'm/s'; } else { - $tunit = '°F'; - $wunit = 'mph'; + $tunit = '°F'; + $wunit = 'mph'; } if ( trim((string)$res->weather['value']) == trim((string)$res->clouds['name']) ) { - $desc = (string)$res->clouds['name']; + $desc = (string)$res->clouds['name']; } else { - $desc = (string)$res->weather['value'].', '.(string)$res->clouds['name']; + $desc = (string)$res->weather['value'].', '.(string)$res->clouds['name']; } $r = [ - 'city'=> (string) $res->city['name'][0], - 'country' => (string) $res->city->country[0], - 'lat' => (string) $res->city->coord['lat'], - 'lon' => (string) $res->city->coord['lon'], - 'temperature' => (string) $res->temperature['value'][0].$tunit, - 'pressure' => (string) $res->pressure['value'].(string)$res->pressure['unit'], - 'humidity' => (string) $res->humidity['value'].(string)$res->humidity['unit'], - 'descripion' => $desc, - 'wind' => (string)$res->wind->speed['name'].' ('.(string)$res->wind->speed['value'].$wunit.')', - 'update' => (string)$res->lastupdate['value'], - 'icon' => (string)$res->weather['icon'] + 'city'=> (string) $res->city['name'][0], + 'country' => (string) $res->city->country[0], + 'lat' => (string) $res->city->coord['lat'], + 'lon' => (string) $res->city->coord['lon'], + 'temperature' => (string) $res->temperature['value'][0].$tunit, + 'pressure' => (string) $res->pressure['value'].(string)$res->pressure['unit'], + 'humidity' => (string) $res->humidity['value'].(string)$res->humidity['unit'], + 'descripion' => $desc, + 'wind' => (string)$res->wind->speed['name'].' ('.(string)$res->wind->speed['value'].$wunit.')', + 'update' => (string)$res->lastupdate['value'], + 'icon' => (string)$res->weather['icon'] ]; PConfig::set(local_user(), 'curweather', 'last', $now->getTimestamp()); Cache::set('curweather'.md5($url), serialize($r), CACHE_HOUR); @@ -69,15 +73,15 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) function curweather_install() { - Addon::registerHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); - Addon::registerHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings'); - Addon::registerHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post'); + Addon::registerHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); + Addon::registerHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings'); + Addon::registerHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post'); } function curweather_uninstall() { - Addon::unregisterHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); - Addon::unregisterHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings'); - Addon::unregisterHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post'); + Addon::unregisterHook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); + Addon::unregisterHook('addon_settings', 'addon/curweather/curweather.php', 'curweather_addon_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/curweather/curweather.php', 'curweather_addon_settings_post'); } function curweather_network_mod_init(&$fk_app,&$b) { @@ -98,114 +102,122 @@ function curweather_network_mod_init(&$fk_app,&$b) { // linked from lat/log of the reply of OWMp $rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc'); - // set the language to the browsers language and use metric units $lang = $_SESSION['language']; $units = PConfig::get( local_user(), 'curweather', 'curweather_units'); $appid = Config::get('curweather','appid'); $cachetime = intval(Config::get('curweather','cachetime')); if ($units==="") - $units = 'metric'; + $units = 'metric'; $ok = true; $res = getWeather($rpt, $units, $lang, $appid, $cachetime); if ($res===false) - $ok = false; + $ok = false; if ($ok) { - $t = get_markup_template("widget.tpl", "addon/curweather/" ); - $curweather = replace_macros ($t, [ - '$title' => L10n::t("Current Weather"), - '$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'), - '$city' => $res['city'], - '$lon' => $res['lon'], - '$lat' => $res['lat'], - '$description' => $res['descripion'], - '$temp' => $res['temperature'], - '$relhumidity' => ['caption'=>L10n::t('Relative Humidity'), 'val'=>$res['humidity']], - '$pressure' => ['caption'=>L10n::t('Pressure'), 'val'=>$res['pressure']], - '$wind' => ['caption'=>L10n::t('Wind'), 'val'=> $res['wind']], - '$lastupdate' => L10n::t('Last Updated').': '.$res['update'].'UTC', - '$databy' => L10n::t('Data by'), - '$showonmap' => L10n::t('Show on map') - ]); + $t = get_markup_template("widget.tpl", "addon/curweather/" ); + $curweather = replace_macros ($t, [ + '$title' => L10n::t("Current Weather"), + '$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'), + '$city' => $res['city'], + '$lon' => $res['lon'], + '$lat' => $res['lat'], + '$description' => $res['descripion'], + '$temp' => $res['temperature'], + '$relhumidity' => ['caption'=>L10n::t('Relative Humidity'), 'val'=>$res['humidity']], + '$pressure' => ['caption'=>L10n::t('Pressure'), 'val'=>$res['pressure']], + '$wind' => ['caption'=>L10n::t('Wind'), 'val'=> $res['wind']], + '$lastupdate' => L10n::t('Last Updated').': '.$res['update'].'UTC', + '$databy' => L10n::t('Data by'), + '$showonmap' => L10n::t('Show on map') + ]); } else { - $t = get_markup_template('widget-error.tpl', 'addon/curweather/'); - $curweather = replace_macros( $t, [ - '$problem' => L10n::t('There was a problem accessing the weather data. But have a look'), - '$rpt' => $rpt, - '$atOWM' => L10n::t('at OpenWeatherMap') - ]); + $t = get_markup_template('widget-error.tpl', 'addon/curweather/'); + $curweather = replace_macros( $t, [ + '$problem' => L10n::t('There was a problem accessing the weather data. But have a look'), + '$rpt' => $rpt, + '$atOWM' => L10n::t('at OpenWeatherMap') + ]); } $fk_app->page['aside'] = $curweather.$fk_app->page['aside']; - } - function curweather_addon_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'curweather-settings-submit'))) - return; - PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); - PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); - PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units'])); - - info(L10n::t('Current Weather settings updated.') . EOL); + if(! local_user() || (! x($_POST,'curweather-settings-submit'))) + return; + PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); + PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); + PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units'])); + + info(L10n::t('Current Weather settings updated.') . EOL); } - function curweather_addon_settings(&$a,&$s) { - if(! local_user()) - return; - - /* Get the current state of our config variable */ - - $curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc'); - $curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units'); - $appid = Config::get('curweather','appid'); - if ($appid=="") { - $noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.'); - } else { - $noappidtext = ''; - } - $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable')); - $enable_checked = (($enable) ? ' checked="checked" ' : ''); - - // load template and replace the macros - $t = get_markup_template("settings.tpl", "addon/curweather/" ); - $s = replace_macros ($t, [ - '$submit' => L10n::t('Save Settings'), - '$header' => L10n::t('Current Weather').' '.L10n::t('Settings'), - '$noappidtext' => $noappidtext, - '$info' => L10n::t('Enter either the name of your location or the zip code.'), - '$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ], - '$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']], - '$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, ''] - ]); - return; - + if(! local_user()) + return; + + /* Get the current state of our config variable */ + + $curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc'); + $curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units'); + $appid = Config::get('curweather','appid'); + if ($appid=="") { + $noappidtext = L10n::t('No APPID found, please contact your admin to obtain one.'); + } else { + $noappidtext = ''; + } + $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable')); + $enable_checked = (($enable) ? ' checked="checked" ' : ''); + + // load template and replace the macros + $t = get_markup_template("settings.tpl", "addon/curweather/" ); + $s = replace_macros ($t, [ + '$submit' => L10n::t('Save Settings'), + '$header' => L10n::t('Current Weather').' '.L10n::t('Settings'), + '$noappidtext' => $noappidtext, + '$info' => L10n::t('Enter either the name of your location or the zip code.'), + '$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ], + '$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']], + '$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, ''] + ]); + return; } + // Config stuff for the admin panel to let the admin of the node set a APPID // for accessing the API of openweathermap function curweather_addon_admin_post (&$a) { - if(! is_site_admin()) - return; - if ($_POST['curweather-submit']) { - Config::set('curweather','appid',trim($_POST['appid'])); - Config::set('curweather','cachetime',trim($_POST['cachetime'])); - info(L10n::t('Curweather settings saved.'.EOL)); - } + if(! is_site_admin()) + return; + if ($_POST['curweather-submit']) { + Config::set('curweather','appid',trim($_POST['appid'])); + Config::set('curweather','cachetime',trim($_POST['cachetime'])); + info(L10n::t('Curweather settings saved.'.EOL)); + } } + function curweather_addon_admin (&$a, &$o) { if(! is_site_admin()) - return; + return; $appid = Config::get('curweather','appid'); $cachetime = Config::get('curweather','cachetime'); $t = get_markup_template("admin.tpl", "addon/curweather/" ); - $o = replace_macros ($t, [ - '$submit' => L10n::t('Save Settings'), - '$cachetime' => ['cachetime', L10n::t('Caching Interval'), $cachetime, L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), ['0'=>L10n::t('no cache'), '300'=>'5 '.L10n::t('minutes'), '900'=>'15 '.L10n::t('minutes'), '1800'=>'30 '.L10n::t('minutes'), '3600'=>'60 '.L10n::t('minutes')]], - '$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')] + $o = replace_macros ($t, [ + '$submit' => L10n::t('Save Settings'), + '$cachetime' => [ + 'cachetime', + L10n::t('Caching Interval'), + $cachetime, + L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), [ + '0'=>L10n::t('no cache'), + '300'=>'5 '.L10n::t('minutes'), + '900'=>'15 '.L10n::t('minutes'), + '1800'=>'30 '.L10n::t('minutes'), + '3600'=>'60 '.L10n::t('minutes') + ] + ], + '$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')] ]); } diff --git a/curweather/templates/widget-error.tpl b/curweather/templates/widget-error.tpl index c5762404..d17d8be8 100644 --- a/curweather/templates/widget-error.tpl +++ b/curweather/templates/widget-error.tpl @@ -1 +1 @@ -
{{$problem}} {{$atOWM}}.
+
{{$problem}} {{$atOWM}}.
diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 2f8c13fe..04d3c7ec 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Queue; @@ -293,7 +292,7 @@ function diaspora_send(&$a,&$b) { // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 0f208037..fcee3260 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -169,6 +169,7 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) { $_SESSION['uid'] = $uid; unset($_REQUEST); + $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; $_REQUEST['profile_uid'] = $uid; diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 832f3df2..48278d5c 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -14,7 +14,6 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Model\Item; @@ -101,7 +100,7 @@ function ifttt_post(App $a) $nickname = $a->argv[1]; - $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]); + $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]); if (!DBM::is_result($user)) { logger('User ' . $nickname . ' not found.', LOGGER_DEBUG); return; @@ -172,6 +171,7 @@ function ifttt_message($uid, $item) $_SESSION['uid'] = $uid; unset($_REQUEST); + $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; $_REQUEST['profile_uid'] = $uid; $_REQUEST['source'] = 'IFTTT'; diff --git a/libertree/libertree.php b/libertree/libertree.php index 7fce4b4e..4d159bf0 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -10,7 +10,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; use Friendica\Util\Network; function libertree_install() { @@ -173,7 +172,7 @@ function libertree_send(&$a,&$b) { // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index 93d0ba65..71b6db5c 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -54,7 +54,7 @@ HTML; function mastodoncustomemojis_put_item_in_cache(App $a, array &$hook_data) { // Mastodon uses OStatus, skipping other network protocols - if (empty($hook_data['item']['author-link']) || ($hook_data['item']['network'] != Protocol::OSTATUS)) { + if ($hook_data['item']['network'] != Protocol::OSTATUS) { return; } diff --git a/public_server/public_server.php b/public_server/public_server.php index a30d3303..0469a576 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -9,7 +9,6 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Database\DBA; use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; @@ -47,7 +46,7 @@ function public_server_register_account($a, $b) } $fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days'), 'expire' => $days_posts]; - DBA::update('user', $fields, ['uid' => $uid]); + dba::update('user', $fields, ['uid' => $uid]); } function public_server_cron($a, $b) @@ -75,7 +74,7 @@ function public_server_cron($a, $b) ]); $fields = ['expire_notification_sent' => DateTimeFormat::utcNow()]; - DBA::update('user', $fields, ['uid' => $rr['uid']]); + dba::update('user', $fields, ['uid' => $rr['uid']]); } } @@ -86,7 +85,7 @@ function public_server_cron($a, $b) if (DBM::is_result($r)) { foreach ($r as $rr) { $fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')]; - DBA::update('user', $fields, ['uid' => $rr['uid']]); + dba::update('user', $fields, ['uid' => $rr['uid']]); } } } @@ -98,7 +97,7 @@ function public_server_cron($a, $b) if (DBM::is_result($r)) { foreach ($r as $rr) { $fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')]; - DBA::update('user', $fields, ['uid' => $rr['uid']]); + dba::update('user', $fields, ['uid' => $rr['uid']]); } } } @@ -110,7 +109,7 @@ function public_server_cron($a, $b) intval($flagposts), dbesc(NULL_DATE)); if (DBM::is_result($r)) { foreach ($r as $rr) { - DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]); + dba::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]); } } } @@ -138,7 +137,7 @@ function public_server_login($a, $b) $fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days')]; $condition = ["`uid` = ? AND `account_expires_on` > ?", local_user(), NULL_DATE]; - DBA::update('user', $fields, $condition); + dba::update('user', $fields, $condition); } function public_server_addon_admin_post(&$a) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 191f8505..479da7d0 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -13,8 +13,6 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Worker; -use Friendica\Database\DBA; -use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Group; @@ -23,6 +21,7 @@ use Friendica\Model\Queue; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Database\DBM; require 'addon/pumpio/oauth/http.php'; require 'addon/pumpio/oauth/oauth_client.php'; @@ -439,7 +438,7 @@ function pumpio_send(&$a, &$b) // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } @@ -825,6 +824,7 @@ function pumpio_fetchtimeline(&$a, $uid) $_SESSION["uid"] = $uid; unset($_REQUEST); + $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; $_REQUEST["source"] = "pump.io"; @@ -952,7 +952,7 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru } $condition = ['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]; - if (DBA::exists('item', $condition)) { + if (dba::exists('item', $condition)) { logger("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); return; } @@ -1079,13 +1079,13 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) { // Two queries for speed issues $condition = ['uri' => $post->object->id, 'uid' => $uid]; - if (DBA::exists('item', $condition)) { + if (dba::exists('item', $condition)) { Item::delete($condition); return true; } $condition = ['extid' => $post->object->id, 'uid' => $uid]; - if (DBA::exists('item', $condition)) { + if (dba::exists('item', $condition)) { Item::delete($condition); return true; } @@ -1110,10 +1110,10 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if ($post->verb != "update") { // Two queries for speed issues - if (DBA::exists('item', ['uri' => $post->object->id, 'uid' => $uid])) { + if (dba::exists('item', ['uri' => $post->object->id, 'uid' => $uid])) { return false; } - if (DBA::exists('item', ['extid' => $post->object->id, 'uid' => $uid])) { + if (dba::exists('item', ['extid' => $post->object->id, 'uid' => $uid])) { return false; } } @@ -1639,11 +1639,11 @@ function pumpio_fetchallcomments(&$a, $uid, $id) } // Checking if the comment already exists - Two queries for speed issues - if (DBA::exists('item', ['uri' => $item->id, 'uid' => $uid])) { + if (dba::exists('item', ['uri' => $item->id, 'uid' => $uid])) { continue; } - if (DBA::exists('item', ['extid' => $item->id, 'uid' => $uid])) { + if (dba::exists('item', ['extid' => $item->id, 'uid' => $uid])) { continue; } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 9af2c6d1..62c3f41b 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -47,8 +47,6 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; -use Friendica\Database\DBM; use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\Item; @@ -57,6 +55,7 @@ use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Database\DBM; function statusnet_install() { @@ -492,7 +491,7 @@ function statusnet_post_hook(App $a, &$b) // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } @@ -833,6 +832,7 @@ function statusnet_fetchtimeline(App $a, $uid) $_SESSION["uid"] = $uid; unset($_REQUEST); + $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; //$_REQUEST["source"] = "StatusNet"; @@ -1074,7 +1074,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['uri'] = $hostname . "::" . $content->id; - if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) { + if (dba::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) { return []; } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 7ed91175..9617a3a0 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -14,7 +14,6 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; function tumblr_install() { Addon::registerHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local'); @@ -332,7 +331,7 @@ function tumblr_send(&$a,&$b) { // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/twitter/twitter.php b/twitter/twitter.php index aa0adfb8..b17cf61a 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -71,10 +71,8 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Worker; -use Friendica\Database\DBA; -use Friendica\Database\DBM; -use Friendica\Model\Contact; use Friendica\Model\GContact; +use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\ItemContent; @@ -83,6 +81,7 @@ use Friendica\Model\User; use Friendica\Object\Image; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Database\DBM; require_once 'boot.php'; require_once 'include/dba.php'; @@ -495,7 +494,7 @@ function twitter_post_hook(App $a, &$b) // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } @@ -734,17 +733,17 @@ function twitter_expire(App $a, $b) return; } - $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]); - while ($row = DBA::fetch($r)) { - DBA::delete('item', ['id' => $row['id']]); - if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) { - DBA::delete('item-activity', ['id' => $row['iaid']]); + $r = dba::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]); + while ($row = dba::fetch($r)) { + dba::delete('item', ['id' => $row['id']]); + if (!empty($row['iaid']) && !dba::exists('item', ['iaid' => $row['iaid']])) { + dba::delete('item-activity', ['id' => $row['iaid']]); } - if (!empty($row['icid']) && !DBA::exists('item', ['icid' => $row['icid']])) { - DBA::delete('item-content', ['id' => $row['icid']]); + if (!empty($row['icid']) && !dba::exists('item', ['icid' => $row['icid']])) { + dba::delete('item-content', ['id' => $row['icid']]); } } - DBA::close($r); + dba::close($r); require_once "include/items.php"; @@ -810,6 +809,7 @@ function twitter_prepare_body(App $a, &$b) */ function twitter_do_mirrorpost(App $a, $uid, $post) { + $datarray["type"] = "wall"; $datarray["api_source"] = true; $datarray["profile_uid"] = $uid; $datarray["extid"] = NETWORK_TWITTER; @@ -1014,11 +1014,11 @@ function twitter_fetch_contact($uid, $data, $create_user) $cid = Contact::getIdForURL($url, 0, true, $fields); if (!empty($cid)) { - DBA::update('contact', $fields, ['id' => $cid]); + dba::update('contact', $fields, ['id' => $cid]); Contact::updateAvatar($avatar, 0, $cid); } - $contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]); + $contact = dba::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]); if (!DBM::is_result($contact) && !$create_user) { return 0; } @@ -1037,11 +1037,11 @@ function twitter_fetch_contact($uid, $data, $create_user) $fields['readonly'] = false; $fields['pending'] = false; - if (!DBA::insert('contact', $fields)) { + if (!dba::insert('contact', $fields)) { return false; } - $contact_id = DBA::lastInsertId(); + $contact_id = dba::lastInsertId(); Group::addMember(User::getDefaultGroup($uid), $contact_id); @@ -1066,7 +1066,7 @@ function twitter_fetch_contact($uid, $data, $create_user) $fields['name-date'] = DateTimeFormat::utcNow(); $fields['uri-date'] = DateTimeFormat::utcNow(); - DBA::update('contact', $fields, ['id' => $contact['id']]); + dba::update('contact', $fields, ['id' => $contact['id']]); } } @@ -1342,7 +1342,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis // $postarray['object'] = json_encode($post); // Activate for debugging // Don't import our own comments - if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) { + if (dba::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) { logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG); return []; } @@ -1515,7 +1515,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, break; } - if (DBA::exists('item', ['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) { + if (dba::exists('item', ['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) { break; } @@ -1660,7 +1660,7 @@ function twitter_fetchhometimeline(App $a, $uid) $notify = false; if ($postarray['uri'] == $postarray['parent-uri']) { - $contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]); + $contact = dba::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]); if (DBM::is_result($contact)) { $notify = Item::isRemoteSelf($contact, $postarray); } diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index c3f5ff15..dd461ea4 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -32,9 +32,8 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; -use Friendica\Model\Item; use Friendica\Model\User; +use Friendica\Model\Item; function windowsphonepush_install() { @@ -463,7 +462,7 @@ function windowsphonepush_login(App $a) $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW'])); if ($user_id) { - $record = DBA::selectFirst('user', [], ['uid' => $user_id]); + $record = dba::selectFirst('user', [], ['uid' => $user_id]); } else { logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); diff --git a/wppost/wppost.php b/wppost/wppost.php index 45b48993..a2c11293 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -11,7 +11,6 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Database\DBA; use Friendica\Util\Network; function wppost_install() { @@ -210,7 +209,7 @@ function wppost_send(&$a,&$b) { // 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]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; }