Move Object\Conversation to Object\Thread
- Move Object\Item to Object\Post
This commit is contained in:
parent
18d93cddf6
commit
70d047ba8e
|
@ -9,7 +9,7 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Object\Conversation;
|
use Friendica\Object\Thread;
|
||||||
use Friendica\Object\Item;
|
use Friendica\Object\Item;
|
||||||
|
|
||||||
require_once "include/bbcode.php";
|
require_once "include/bbcode.php";
|
||||||
|
@ -840,7 +840,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||||
// Normal View
|
// Normal View
|
||||||
$page_template = get_markup_template("threaded_conversation.tpl");
|
$page_template = get_markup_template("threaded_conversation.tpl");
|
||||||
|
|
||||||
$conv = new Conversation($mode, $preview);
|
$conv = new Thread($mode, $preview);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get all the topmost parents
|
* get all the topmost parents
|
||||||
|
@ -881,7 +881,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||||
|
|
||||||
if ($item['id'] == $item['parent']) {
|
if ($item['id'] == $item['parent']) {
|
||||||
$item_object = new Item($item);
|
$item_object = new Item($item);
|
||||||
$conv->addThread($item_object);
|
$conv->addParent($item_object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file src/Object/Item.php
|
* @file src/Object/Post.php
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Object;
|
namespace Friendica\Object;
|
||||||
|
|
||||||
use Friendica\BaseObject;
|
use Friendica\BaseObject;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Object\Contact;
|
use Friendica\Model\Contact;
|
||||||
use dba;
|
use dba;
|
||||||
|
|
||||||
require_once 'include/text.php';
|
require_once 'include/text.php';
|
||||||
require_once 'boot.php';
|
require_once 'boot.php';
|
||||||
require_once "include/conversation.php";
|
require_once 'include/conversation.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An item
|
* An item
|
||||||
*/
|
*/
|
||||||
class Item extends BaseObject
|
class Post extends BaseObject
|
||||||
{
|
{
|
||||||
private $data = array();
|
private $data = array();
|
||||||
private $template = null;
|
private $template = null;
|
||||||
|
@ -32,7 +31,7 @@ class Item extends BaseObject
|
||||||
private $writable = false;
|
private $writable = false;
|
||||||
private $children = array();
|
private $children = array();
|
||||||
private $parent = null;
|
private $parent = null;
|
||||||
private $conversation = null;
|
private $thread = null;
|
||||||
private $redirect_url = null;
|
private $redirect_url = null;
|
||||||
private $owner_url = '';
|
private $owner_url = '';
|
||||||
private $owner_photo = '';
|
private $owner_photo = '';
|
||||||
|
@ -139,7 +138,7 @@ class Item extends BaseObject
|
||||||
$osparkle = '';
|
$osparkle = '';
|
||||||
$total_children = $this->countDescendants();
|
$total_children = $this->countDescendants();
|
||||||
|
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getThread();
|
||||||
|
|
||||||
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|
||||||
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
||||||
|
@ -540,7 +539,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parent = $item;
|
$this->parent = $item;
|
||||||
$this->setConversation($item->getConversation());
|
$this->setThread($item->getThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -551,7 +550,7 @@ class Item extends BaseObject
|
||||||
protected function removeParent()
|
protected function removeParent()
|
||||||
{
|
{
|
||||||
$this->parent = null;
|
$this->parent = null;
|
||||||
$this->conversation = null;
|
$this->thread = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -594,15 +593,15 @@ class Item extends BaseObject
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setConversation($conv)
|
public function setThread($conv)
|
||||||
{
|
{
|
||||||
$previous_mode = ($this->conversation ? $this->conversation->getMode() : '');
|
$previous_mode = ($this->thread ? $this->thread->getMode() : '');
|
||||||
|
|
||||||
$this->conversation = $conv;
|
$this->thread = $conv;
|
||||||
|
|
||||||
// Set it on our children too
|
// Set it on our children too
|
||||||
foreach ($this->getChildren() as $child) {
|
foreach ($this->getChildren() as $child) {
|
||||||
$child->setConversation($conv);
|
$child->setThread($conv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,9 +610,9 @@ class Item extends BaseObject
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function getConversation()
|
public function getThread()
|
||||||
{
|
{
|
||||||
return $this->conversation;
|
return $this->thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -690,7 +689,7 @@ class Item extends BaseObject
|
||||||
*/
|
*/
|
||||||
private function isWritable()
|
private function isWritable()
|
||||||
{
|
{
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getThread();
|
||||||
|
|
||||||
if ($conv) {
|
if ($conv) {
|
||||||
// This will allow us to comment on wall-to-wall items owned by our friends
|
// This will allow us to comment on wall-to-wall items owned by our friends
|
||||||
|
@ -748,7 +747,7 @@ class Item extends BaseObject
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
$comment_box = '';
|
$comment_box = '';
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getThread();
|
||||||
$template = get_markup_template($this->getCommentBoxTemplate());
|
$template = get_markup_template($this->getCommentBoxTemplate());
|
||||||
$ww = '';
|
$ww = '';
|
||||||
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
|
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
|
||||||
|
@ -819,7 +818,7 @@ class Item extends BaseObject
|
||||||
protected function checkWallToWall()
|
protected function checkWallToWall()
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getThread();
|
||||||
$this->wall_to_wall = false;
|
$this->wall_to_wall = false;
|
||||||
|
|
||||||
if ($this->isToplevel()) {
|
if ($this->isToplevel()) {
|
||||||
|
@ -889,14 +888,6 @@ class Item extends BaseObject
|
||||||
return $this->owner_url;
|
return $this->owner_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getOwnerPhoto()
|
|
||||||
{
|
|
||||||
return $this->owner_photo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file src/Object/Conversation.php
|
* @file src/Object/Thread.php
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Object;
|
namespace Friendica\Object;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ require_once 'include/text.php';
|
||||||
*
|
*
|
||||||
* We should think about making this a SPL Iterator
|
* We should think about making this a SPL Iterator
|
||||||
*/
|
*/
|
||||||
class Conversation extends BaseObject
|
class Thread extends BaseObject
|
||||||
{
|
{
|
||||||
private $threads = array();
|
private $parents = array();
|
||||||
private $mode = null;
|
private $mode = null;
|
||||||
private $writable = false;
|
private $writable = false;
|
||||||
private $profile_owner = 0;
|
private $profile_owner = 0;
|
||||||
|
@ -120,7 +120,7 @@ class Conversation extends BaseObject
|
||||||
* @return mixed The inserted item on success
|
* @return mixed The inserted item on success
|
||||||
* false on failure
|
* false on failure
|
||||||
*/
|
*/
|
||||||
public function addThread($item)
|
public function addParent($item)
|
||||||
{
|
{
|
||||||
$item_id = $item->getId();
|
$item_id = $item->getId();
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class Conversation extends BaseObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getThread($item->getId())) {
|
if ($this->getParent($item->getId())) {
|
||||||
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,10 +147,10 @@ class Conversation extends BaseObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->setConversation($this);
|
$item->setThread($this);
|
||||||
$this->threads[] = $item;
|
$this->parents[] = $item;
|
||||||
|
|
||||||
return end($this->threads);
|
return end($this->parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +169,7 @@ class Conversation extends BaseObject
|
||||||
$result = array();
|
$result = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
foreach ($this->threads as $item) {
|
foreach ($this->parents as $item) {
|
||||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -194,9 +194,9 @@ class Conversation extends BaseObject
|
||||||
* @return mixed The found item on success
|
* @return mixed The found item on success
|
||||||
* false on failure
|
* false on failure
|
||||||
*/
|
*/
|
||||||
private function getThread($id)
|
private function getParent($id)
|
||||||
{
|
{
|
||||||
foreach ($this->threads as $item) {
|
foreach ($this->parents as $item) {
|
||||||
if ($item->getId() == $id) {
|
if ($item->getId() == $id) {
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
Loading…
Reference in a new issue