]> git.mxchange.org Git - friendica.git/blobdiff - mod/tagger.php
Docs: add a note on adding `use` on theme.php
[friendica.git] / mod / tagger.php
index 942cad2ad5b5f5957b943603949306798a92e7b2..16195cc339d2f02f4c04eb719f7e7b04484e1e98 100644 (file)
@@ -8,9 +8,9 @@ use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
+use Friendica\Model\Item;
 
 require_once 'include/security.php';
-require_once 'include/bbcode.php';
 require_once 'include/items.php';
 
 function tagger_content(App $a) {
@@ -43,6 +43,8 @@ function tagger_content(App $a) {
        $item = $r[0];
 
        $owner_uid = $item['uid'];
+       $owner_nick = '';
+       $blocktags = 0;
 
        $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
                intval($owner_uid)
@@ -70,8 +72,13 @@ function tagger_content(App $a) {
        $post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
        $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
 
-       $link = xmlify('<link rel="alternate" type="text/html" href="'
-               . System::baseUrl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+       if ($owner_nick) {
+               $href = System::baseUrl() . '/display/' . $owner_nick . '/' . $item['id'];
+       } else {
+               $href = System::baseUrl() . '/display/' . $item['guid'];
+       }
+
+       $link = xmlify('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n") ;
 
        $body = xmlify($item['body']);
 
@@ -145,32 +152,18 @@ EOT;
        $arr['unseen'] = 1;
        $arr['origin'] = 1;
 
-       $post_id = item_store($arr);
-
-//     q("UPDATE `item` set plink = '%s' where id = %d",
-//             dbesc(System::baseUrl() . '/display/' . $owner_nick . '/' . $post_id),
-//             intval($post_id)
-//     );
+       $post_id = Item::insert($arr);
 
-
-       if(! $item['visible']) {
-               $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
-                       intval($item['id']),
-                       intval($owner_uid)
-               );
+       if (!$item['visible']) {
+               Item::update(['visible' => true], ['id' => $item['id']]);
        }
 
-       $term_objtype = (($item['resource-id']) ? TERM_OBJ_PHOTO : TERM_OBJ_POST );
+       $term_objtype = ($item['resource-id'] ? TERM_OBJ_PHOTO : TERM_OBJ_POST);
         $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
                 intval($item['id']),
                 dbesc($term)
         );
        if((! $blocktags) && $t[0]['tcount']==0 ) {
-               /*q("update item set tag = '%s' where id = %d",
-                       dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . System::baseUrl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
-                       intval($item['id'])
-               );*/
-
                q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
                   intval($item['id']),
                   $term_objtype,
@@ -204,14 +197,6 @@ EOT;
                           intval($owner_uid)
                        );
                }
-
-               /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
-                       q("update item set tag = '%s' where id = %d",
-                               dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . System::baseUrl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
-                               intval($r[0]['id'])
-                       );
-               }*/
-
        }
 
 
@@ -224,6 +209,4 @@ EOT;
        killme();
 
        return; // NOTREACHED
-
-
 }