]> git.mxchange.org Git - friendica-addons.git/blobdiff - advancedcontentfilter/advancedcontentfilter.php
numfriends addon HU translation added THX Balázs Úr
[friendica-addons.git] / advancedcontentfilter / advancedcontentfilter.php
index 415cf48c1e161b5b4d691a75cc5596ae135d3a4f..145887cc261a1b28475791565d17e2b80fdd6409 100644 (file)
@@ -37,14 +37,14 @@ use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Content\Text\Markdown;
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
 use Friendica\DI;
 use Friendica\Model\Item;
-use Friendica\Model\Term;
+use Friendica\Model\Post;
+use Friendica\Model\Tag;
 use Friendica\Module\Security\Login;
 use Friendica\Network\HTTPException;
 use Friendica\Util\DateTimeFormat;
@@ -61,18 +61,11 @@ function advancedcontentfilter_install(App $a)
        Hook::register('addon_settings'             , __FILE__, 'advancedcontentfilter_addon_settings');
 
        Hook::add('dbstructure_definition'          , __FILE__, 'advancedcontentfilter_dbstructure_definition');
-       DBStructure::update($a->getBasePath(), false, true);
+       DBStructure::performUpdate();
 
        Logger::log("installed advancedcontentfilter");
 }
 
-function advancedcontentfilter_uninstall()
-{
-       Hook::unregister('dbstructure_definition'     , __FILE__, 'advancedcontentfilter_dbstructure_definition');
-       Hook::unregister('prepare_body_content_filter', __FILE__, 'advancedcontentfilter_prepare_body_content_filter');
-       Hook::unregister('addon_settings'             , __FILE__, 'advancedcontentfilter_addon_settings');
-}
-
 /*
  * Hooks
  */
@@ -331,7 +324,7 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request)
        try {
                $fields = advancedcontentfilter_build_fields($data);
        } catch (Exception $e) {
-               throw new HTTPException\BadRequestException($e->getMessage(), 0, $e);
+               throw new HTTPException\BadRequestException($e->getMessage(), $e);
        }
 
        if (empty($fields['name']) || empty($fields['expression'])) {
@@ -369,11 +362,11 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res
        try {
                $fields = advancedcontentfilter_build_fields($data);
        } catch (Exception $e) {
-               throw new HTTPException\BadRequestException($e->getMessage(), 0, $e);
+               throw new HTTPException\BadRequestException($e->getMessage(), $e);
        }
 
        if (!DBA::update('advancedcontentfilter_rules', $fields, ['id' => $args['id']])) {
-               throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage());
+               throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
        }
 
        return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]);
@@ -394,7 +387,7 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request,
        }
 
        if (!DBA::delete('advancedcontentfilter_rules', ['id' => $args['id']])) {
-               throw new HTTPException\ServiceUnavaiableException(DBA::errorMessage());
+               throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
        }
 
        return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]);
@@ -412,13 +405,13 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
 
        $condition = ["`guid` = ? AND (`uid` = ? OR `uid` = 0)", $args['guid'], local_user()];
        $params = ['order' => ['uid' => true]];
-       $item = Item::selectFirstForUser(local_user(), [], $condition, $params);
+       $item = Post::selectFirstForUser(local_user(), [], $condition, $params);
 
        if (!DBA::isResult($item)) {
                throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown post with guid: %s', $args['guid']));
        }
 
-       $tags = Term::populateTagsFromItem($item);
+       $tags = Tag::populateFromItem($item);
 
        $item['tags'] = $tags['tags'];
        $item['hashtags'] = $tags['hashtags'];