1
0
Fork 0

Move Object\Conversation to Object\Thread

- Move Object\Item to Object\Post
This commit is contained in:
Hypolite Petovan 2017-12-07 09:05:23 -05:00
parent a42595a30c
commit 3772cf7544
3 changed files with 28 additions and 37 deletions

View file

@ -840,7 +840,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
// Normal View
$page_template = get_markup_template("threaded_conversation.tpl");
$conv = new Conversation($mode, $preview);
$conv = new Thread($mode, $preview);
/*
* get all the topmost parents

View file

@ -1,25 +1,24 @@
<?php
/**
* @file src/Object/Item.php
* @file src/Object/Post.php
*/
namespace Friendica\Object;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use dba;
require_once 'include/text.php';
require_once 'boot.php';
require_once "include/conversation.php";
require_once 'include/conversation.php';
/**
* An item
*/
class Item extends BaseObject
class Post extends BaseObject
{
private $data = array();
private $template = null;
@ -32,7 +31,7 @@ class Item extends BaseObject
private $writable = false;
private $children = array();
private $parent = null;
private $conversation = null;
private $thread = null;
private $redirect_url = null;
private $owner_url = '';
private $owner_photo = '';
@ -139,7 +138,7 @@ class Item extends BaseObject
$osparkle = '';
$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'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
@ -540,7 +539,7 @@ class Item extends BaseObject
}
$this->parent = $item;
$this->setConversation($item->getConversation());
$this->setThread($item->getThread());
}
/**
@ -551,7 +550,7 @@ class Item extends BaseObject
protected function removeParent()
{
$this->parent = null;
$this->conversation = null;
$this->thread = null;
}
/**
@ -594,15 +593,15 @@ class Item extends BaseObject
*
* @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
foreach ($this->getChildren() as $child) {
$child->setConversation($conv);
$child->setThread($conv);
}
}
@ -611,9 +610,9 @@ class Item extends BaseObject
*
* @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()
{
$conv = $this->getConversation();
$conv = $this->getThread();
if ($conv) {
// 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();
$comment_box = '';
$conv = $this->getConversation();
$conv = $this->getThread();
$template = get_markup_template($this->getCommentBoxTemplate());
$ww = '';
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
@ -819,7 +818,7 @@ class Item extends BaseObject
protected function checkWallToWall()
{
$a = self::getApp();
$conv = $this->getConversation();
$conv = $this->getThread();
$this->wall_to_wall = false;
if ($this->isToplevel()) {
@ -889,14 +888,6 @@ class Item extends BaseObject
return $this->owner_url;
}
/**
* @return string
*/
private function getOwnerPhoto()
{
return $this->owner_photo;
}
/**
* @return string
*/

View file

@ -1,6 +1,6 @@
<?php
/**
* @file src/Object/Conversation.php
* @file src/Object/Thread.php
*/
namespace Friendica\Object;
@ -15,9 +15,9 @@ require_once 'include/text.php';
*
* 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 $writable = false;
private $profile_owner = 0;
@ -129,7 +129,7 @@ class Conversation extends BaseObject
return false;
}
if ($this->getThread($item->getId())) {
if ($this->getParent($item->getId())) {
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
return false;
}
@ -147,10 +147,10 @@ class Conversation extends BaseObject
return false;
}
$item->setConversation($this);
$this->threads[] = $item;
$item->setThread($this);
$this->parents[] = $item;
return end($this->threads);
return end($this->parents);
}
/**
@ -169,7 +169,7 @@ class Conversation extends BaseObject
$result = array();
$i = 0;
foreach ($this->threads as $item) {
foreach ($this->parents as $item) {
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
continue;
}
@ -194,9 +194,9 @@ class Conversation extends BaseObject
* @return mixed The found item on success
* 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) {
return $item;
}