mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-17 04:15:15 +02:00
Update functions and calls
Change function names, calls and use dba functions.
This commit is contained in:
parent
55ee9a1c72
commit
dc175b8e12
5 changed files with 24 additions and 24 deletions
|
@ -7,10 +7,10 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Model\Term;
|
||||
use dba;
|
||||
|
||||
require_once 'include/tags.php';
|
||||
require_once 'include/files.php';
|
||||
require_once 'include/threads.php';
|
||||
|
||||
class Item
|
||||
|
@ -52,7 +52,7 @@ class Item
|
|||
}
|
||||
|
||||
create_tags_from_item($item['id']);
|
||||
create_files_from_item($item['id']);
|
||||
Term::createFromItem($item['id']);
|
||||
update_thread($item['id']);
|
||||
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);
|
||||
|
|
|
@ -4,15 +4,17 @@
|
|||
*/
|
||||
namespace Friendica\Model;
|
||||
|
||||
use dba;
|
||||
|
||||
class Term
|
||||
{
|
||||
/**
|
||||
* @param integer $itemid item id
|
||||
* @return void
|
||||
*/
|
||||
function create_files_from_item($itemid)
|
||||
public static function createFromItem($itemid)
|
||||
{
|
||||
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
|
||||
$messages = dba::selectFirst('item', ['guid', 'uid', 'id', 'edited', 'deleted', 'file', 'parent'], ['id' => $itemid]);
|
||||
if (!$messages) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,15 +33,13 @@ class Term
|
|||
|
||||
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
|
||||
foreach ($files[1] as $file) {
|
||||
q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
|
||||
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_FILE), dbesc($file));
|
||||
dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_FILE, 'term' => $file]);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
|
||||
foreach ($files[1] as $file) {
|
||||
q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
|
||||
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), dbesc($file));
|
||||
dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_CATEGORY, 'term' => $file]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,26 +49,26 @@ class Term
|
|||
* @param integer $uid uid
|
||||
* @return void
|
||||
*/
|
||||
function create_files_from_itemuri($itemuri, $uid)
|
||||
public static function createFromItemURI($itemuri, $uid)
|
||||
{
|
||||
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
|
||||
|
||||
if (count($messages)) {
|
||||
foreach ($messages as $message)
|
||||
create_files_from_item($message["id"]);
|
||||
self::createFromItem($message["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
function update_files_for_items()
|
||||
private function update_files_for_items()
|
||||
{
|
||||
$messages = q("SELECT `id` FROM `item` where file !=''");
|
||||
|
||||
foreach ($messages as $message) {
|
||||
echo $message["id"] . "\n";
|
||||
create_files_from_item($message["id"]);
|
||||
self::createFromItem($message["id"]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\Term;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
@ -32,7 +33,6 @@ require_once "include/enotify.php";
|
|||
require_once "include/threads.php";
|
||||
require_once "include/items.php";
|
||||
require_once "include/tags.php";
|
||||
require_once "include/files.php";
|
||||
require_once "include/event.php";
|
||||
require_once "include/text.php";
|
||||
require_once "include/html2bbcode.php";
|
||||
|
@ -2912,7 +2912,7 @@ class DFRN
|
|||
intval($importer["uid"])
|
||||
);
|
||||
create_tags_from_itemuri($uri, $importer["uid"]);
|
||||
create_files_from_itemuri($uri, $importer["uid"]);
|
||||
Term::createFromItemURI($uri, $importer["uid"]);
|
||||
update_thread_uri($uri, $importer["uid"]);
|
||||
} else {
|
||||
$r = q(
|
||||
|
@ -2925,7 +2925,7 @@ class DFRN
|
|||
intval($importer["uid"])
|
||||
);
|
||||
create_tags_from_itemuri($uri, $importer["uid"]);
|
||||
create_files_from_itemuri($uri, $importer["uid"]);
|
||||
Term::createFromItemURI($uri, $importer["uid"]);
|
||||
update_thread_uri($uri, $importer["importer_uid"]);
|
||||
if ($item["last-child"]) {
|
||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue